Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I restrict access to my ContentProvider to only my apps?

I want to export a ContentProvider for use by another one of MY apps. How do I prevent other apps from accessing it? If I use an android:permission attribute, can't 3rd party apps just apply that permission to their app? I really need to lock down access to my apps only.

Thanks in advance...

like image 301
Barry Fruitman Avatar asked Apr 24 '14 23:04

Barry Fruitman


People also ask

How do I set custom permissions on Android?

You can use the sharedUserId attribute in the AndroidManifest. xml 's manifest tag of each package to have them assigned the same user ID. By doing this, for purposes of security the two packages are then treated as being the same app, with the same user ID and file permissions.

Can I turn off permissions on Android phone for apps?

An app will send a notification to ask for permission to use features on your phone, which you can Allow or Deny. You can also change permissions for a single app or by permission type in your phone's Settings.


1 Answers

If I use an android:permission attribute, can't 3rd party apps just apply that permission to their app?

Well, you can use a signature-level custom permission (android:protectionLevel="signature"). Then, the app holding the permission and the app defending itself with the permission have to be signed by the same signing key.

There's a bug/limitation in Android that can allow an attacker, installed before your app, to hold this permission even though the attacker is not signed by your signing key. I go into that in more detail in this report (as it's a bit complex for an SO answer) and have a PermissionUtils class to help you detect that case.

like image 187
CommonsWare Avatar answered Nov 06 '22 12:11

CommonsWare