Controlling the Information Your Android Apps Send Home
by Aaron Grothe (firstname.lastname@example.org)
I have my Android phone set to auto update all my apps, so I know when I have to manually update an app there has been a permission change.
This has never been a good thing. For instance, a game about mad avians decides that it needs to be able to read my Device ID and contacts. An application for playing music suddenly needs to be able to take screenshots of other apps. I'm already using and like these apps, so I consider this to be a sneaky way to make a land grab. What to do? For some apps you are forced to upgrade if you want to continue to use the service, as in the case of the music app. For others, you can keep running the old version until the next time you replace your phone. Another answer is to try and grab some permissions back from these apps, hopefully in a way in which they will continue to work.
If you have a rooted and unlocked phone, you have several options to pull back some permissions from your apps. In this article, we're going to talk about three methods: CyanogenMod 7's Permissions Management, PDroid, and OpenPDroid ROM modules and custom patches against the CyanogenMod source code tree.
There are several different ways of altering the information that an app running on a smart phone makes available. Typically, you will either deny the access or alter the data that is sent from the phone. An example of altering the data is sending a random Device ID instead of your real Device ID or a fake latitude/longitude instead of your real one. You can also have the system block the access.
CyanogenMod (CM) 7 provides an easy way to revoke privileges through the Permission management. This feature has been removed from CM 9 and later. Many poorly written apps will do a Force Close after being denied a privilege, so this feature is not being brought over to newer versions of CyanogenMod.
PDroid and OpenPDroid offer you a bit more control over permission management than CyanogenMod as they intercept requests and for many of them, such as a Device ID request, can either return a random or user chosen value. Returning a value allows a lot of apps to continue working instead of just doing a Force Close. You'll need to create a custom module for the ROM you have installed on your phone. You'll also need a GUI for controlling the module. The preferred GUI for controlling permissions is PDroid Manager.
CyanogenMod's source code is also available and there are patches out there that allow you to modify the source code tree to do things such as return random Geo location, Device ID, Android ID information, and so on. After incorporating these patches, you can build your own custom ROM and install it on your smart phone, and the phone will always return either random or user chosen values compiled into the ROM. The major problem here is most of these patches are all or nothing. Having mad avians not know your latitude and longitude is fine, but for Google Maps it is kind of a pain for them to think you are in Forman, North Dakota unless you are.
The following is a quick example of restricting an application's permissions using OpenPDroid and the PDroid Manager. The app chosen was Duke Nukem 3D. This was chosen because it is a game I play every now and then, and it shouldn't need to know my phone number anyway.
For this example, I used a pretty simple policy. If it is possible to set it to random (Device ID, phone number, etc.), set it to random, otherwise set it to deny. I also set it to log and notify for access requests. Here is a quick screenshot of the full permissions for the application.
With this policy, you'll see several notices as the application starts up as follows:
Random Device ID returned to App
Random Android ID returned to App
Network Information Access Denied
After this, the game seems to run pretty well, with minimal information handed over!
The following are a couple of hints that will hopefully make your experiments go better.
These are all based on my personal experiences and your mileage may vary:
- Use a CyanogenMod ROM instead of trying to use the ROM that came with your phone. I've been able to create modules for some stock ROMs, but have had better luck with CM ROMs.
- If you use Cyanogenmod's Permission Management to remove privileges from your phone, a lot of your apps might do Force Closes. This is why PDroid/OpenPDroid tends to be a better solution.
- Use ClockworkMod ROM Manager to flash/backup/restore your phones. This will save you countless time.
- Every five minutes spent in the XDA forums will, on average, save you an hour of frustration later.
- If you have an HTC device, you can unlock it using the HTCdev site. It is a lot easier than having to downgrade your phone to a vulnerable ROM to get root access on it.
- Use Auto-Patcher to generate modules for PDroid and OpenPDroid. You can do it by hand, but it isn't worth the pain, except as a learning experience.
- Permission restriction can be a bit of trial and error. Start with very strict and, if the app Force Closes, you can give it back a few permissions until it works again.
- If something goes wrong on your phone when you install your PDroid or OpenPDroid patch, you can either use the restore ZIP file or just do a fresh reinstall of the original ROM.
- I prefer OpenPDroid as I have had better luck getting working modules with it than PDroid. Your mileage may vary, though. Depending on what Android version you are running, you might have to use one or the other. They both largely work the same, so if one doesn't work for you, try the other one.
- If you want to get a quick summary of the permissions that you have given away on your phone, I recommend you give PermissionDog a quick install. It provides a high level summary of some of the more dangerous permissions you have already probably allowed apps on your phone to have.
The next major step in terms of privilege control on smart phones will probably be done using virtualization.
If you run Android inside a VM, you can intercept the calls to the hardware and provide the guest operating system whatever values you want, with the guest operating system being none the wiser. This is going to require more power than most smart phones have today.
The design of Google's Android with its relatively granular permissions and open-source nature allows for people to get some control over what information is sent from their phones. This is by no means a foolproof way of restricting apps from sharing your information, but it is a very good first step and hopefully these solutions will continue to evolve and get better.
Auto-Patcher - forum.xda-developers.com/showthread.php?t=1719408 - Tool that makes it easier to generate ZIP files for installing PDroid and OpenPDroid. It can also do a lot more. Well worth a look.
ClockworkMod ROM Manager - www.clockworkmod.com - Makes doing restores/backup/updates as easy as it can be.
Cyanogenmod - www.cyanogenmod.org - Alternative firmware for Android phones and tablets based upon the Google Android releases.
HTCdev - www.htcdev.com - HTC is allowing people to unlock the vast majority of their phones. If you have an HTC phone, this is very nice.
OpenPDroid - forum.xda-developers.com/showthread.php?t=2098156 - Developers of the OpenPDroid kernel module.
PDroid - forum.xda-developers.com/showthread.php?t=1923576 - Developers of the PDroid kernel module.
PDroid Manager - forum.xda-developers.com/showthread.php?p=34190204 - GUI front-end for managing permissions with PDroid or OpenPDroid installed.
PermissionDog - apkpure.com/permissiondog/com.PermissioDog - Great app that provides a lot of information about the permission settings on your phone.
XDA Forums - forum.xda-developers.com - The place to go for more information and troubleshooting on issues with permissions.