[FIX][XPOSED][4.0+] Universal fix for the several "Master Key" vulnerabilities
You may be aware of recent news about several different security vulnerabilities
that allow replacing code on a signed APK without invalidating the signature:
Master Key (Bug 8219321)
An issue related with duplicate entries on the ZIP / APK files.
It was patched by Google back in February 2013 and shared with OEMs, and some of the newer devices might have already received the fix in a recent stock update. At least both Xperia Z 4.2.2 and Galaxy S2 4.1.2 contain the fix; CM has also recently patched it, on this commit
More info can be found on @Adam77Root
's thread here: http://forum.xda-developers.com/show....php?t=2359943
This also originates in the ZIP file parsing routines, and was disclosed just a few days ago immediately after the previous one was made public. The correction has already been applied by Google to the code (this commit
), but it's very likely that its rollout on stock ROMs will take a long time especially on non-Nexus devices.
You can read more about it here
To know if you're vulnerable, use SRT AppScanner mentioned above.
Unless you're running CM 10.1.2
, there's a fairly big chance that you have this issue, at least as of this moment.
It's yet another inconsistency in ZIP parsing that could be abused in very a similar way to the previous one.
This one is a bit special to me, since I was fortunate enough to be the first one to report it on Google's bugtracker
It was discovered around the time that the previous bug was acknowledged and Android 4.3 was a few days from being released, but despite the prompt report it was unfortunately too late to include the fix in time for the release; Therefore it wasn't disclosed till Android 4.4 sources came out and I had also decided not including a fix for in on this module, since it would be an easy way to learn about the extra attack vector.
Kudos to Jeff Forristal at Bluebox Security, who I learned was also working on that exact problem and helped me report it properly to Google, and also to Saurik who already released a Substrate-based fix and has written a very interesting article about it here
Checking if you're vulnerable
You can use some 3rd party apps to test your system, such as:
- SRT AppScanner
- Bluebox Security Scanner
On Android 4.4 all these bugs should be fixed, and therefore this mod is not needed. But you can run one of these scanners to make sure you're not vulnerable.
While technically different, these vulnerabilities permit that legitimate APKs can be manipulated to replace the original code with arbitrary one without breaking the signature. This allows someone to take an update from a well known publisher (e.g. Google Maps), change the APK, and a device receiving it will happily apply the update as if it was indeed from that publisher. Depending on the apps being updated in this way, priviledge escalation can be achieved.
Google has already mentioned that all apps published on the Play Store are checked for this kind of manipulation, but those of us installing APKs from other sources aren't safe.
The universal fix
Since decompiling, fixing and recompiling the code for every possible ROM version is way beyond anyone's capability, the awesome Xposed framework
proves itself once again as an invaluable tool.
By creating hooks around the vulnerable methods and replacing the buggy implementation with a safe one, it's possible to patch the 2 issues on the fly without ever changing the original files. Applying the fix is as easy as installing and enabling an Xposed module.
1. Make sure the Xposed Framework
Follow the instructions on the thread. Root is required only during installation, it is no longer required afterwards. Only ICS or above is supported.
2. Install the Master Key multi-fix
3. Follow the Xposed notification about a new module being available, and on the list of modules activate Master Key multi-fix
You should now see an image similar to the attached one when opening the app. The green text
shows that the module is active and the vulnerabilities have been patched in memory.
Grab it from Google Play
(recommended, as you'll get updates) or use the attached APK. The files are the same.
- Fix bug 9950697; additional corrections taken from Android 4.4 (also supports GB
, provided you have a working version of Xposed Framework for your ROM)
- Fixed problems with parsing some zips depending on the rom original code
- Added 2 additional zip entry integrity checks that were missing
- Support for additional devices with modified core libraries (e.g. MTK6589)
- Initial version
Available on GitHub
If you appreciated this fix, consider donating with Paypal