8

I want to develop two Android apps that will communicate via intents (on the same device).

When the two apps transfer confidential data, should they encrypt it?

Or does the Android OS guarantee (or at least try to guarantee) that intent data is not seen by anyone but sender and recipient?

Of course, let's suppose the user always selects my app as the receiver of the intent.
Let's also say that both apps are installed, that should prevent namespace hijacking.

1 Answer 1

6

No, the Android OS doesn't guarantee that intent data is not seen by anyone. Any malicious app implementing the intent filter is able to receive the message and thus get hold of your sensitive data. Encrypting data is good idea but make sure that:

  1. the key used for encryption is not stored on the SD card.
  2. you are not hard-coding the key in the app as it is very trivial to get the source from the apk.

Also, make sure that only the app(s) which are intended to receive the message (via intents) are receiving the intent and that no other app is able to receive that intent. If you want to communicate confidential data and if you know the class names the apps that would be communicating via intents, you can either ensure that only that specific app receives the intent by using the setClassname() method of the intents. For ex:

Intent i = new Intent(); 
i.setClassName(“your.pkg.name”, “your.pkg.name.Destination”);

or by letting apps having only specific permissions receive the intent. For ex:

Intent i = new Intent(); 
i.setAction(“your.own.action”); 
sendBroadcast(i, “your.own.permission”);

Source: "Seven Ways to Hang Yourself with Google Android" (Defcon 19)

6
  • I suppose that the user always selects my app as the receiver of the intent. Even this case, is your first paragraph still true? The setClassname paragraph is great! Mar 31, 2014 at 8:52
  • What do you mean by "user always selects my app as the receiver of the intent"? How are you "selecting" your app without specifying the class (i.e without using setClassName)? Mar 31, 2014 at 9:03
  • Note that a (malicious) application can have any package name (unless an application already exists with that package name).
    – domen
    Mar 31, 2014 at 10:03
  • @TheRookierLearner: If I choose a standard intent like ACTION_EDIT/etc there might be other apps handling the same intent. In such cases the user is shown a dialog to choose. Mar 31, 2014 at 10:38
  • So, consider that you show a list of apps handling the same intent (say: {A, B and C}) and the user chooses say B. (I suppose you mean something like you are having a list and saving the index corresponding to B and then sending your data to B) You still either need to set the class name using setClassName otherwise A and C can listen for the same data or list the permission that only B has (uniquely) and no other app has that permission. Mar 31, 2014 at 16:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .