[MOD][XPOSED][2.3.3+]FakeID vulnerability fix 1.1 [2014-08-10]

Search This thread

Tungstwenty

Senior Member
Nov 1, 2011
1,830
4,512
There is a new security vulnerability in town, this time labeled "Fake ID" (Google bug 13678484).

The bug allows malicious apps to pretend to be signed by trusted providers and be loaded as extensions in several contexts such as NFC access, browser plugins and others.
An excellent explanation can be found on this article by Jeff Forristal from Bluebox.


Checking if you're vulnerable
It appears to currently affect all devices, to a lesser or greater extent depending on which extensions each manufacturer included in their ROMs.
You can use Bluebox Security Scanner to detect if your system is vulnerable.


Installing the fix
Fetch the package from the Xposed repository: http://repo.xposed.info/module/tungstwenty.xposed.fakeidfix (it is also available on Google play)
Install as usual and make sure that you enable the module on the Xposed Installer and reboot.

There are no configuration options. There is a simple information screen which can be accessed by tapping the entry on the Installer's module list (you won't see an icon for this on your launcher).


Fix details
For the tech savvy, here's an explanation of what this patch does.
The JarTools class has an API for grabbing all signature certificatates present on an APK / jar. That API doesn't however check if *all* certificates form a valid chain, where each certificate is properly signed by the next one and so on, and not additional certificates are present that don't belong to that chain. It is therefore possible to insert additional certificates in that list, and *certain* callers of that API might be fooled if they assume that just because a certificate is on that list, the party to which it belongs did in fact sign or trust that code.
This behavior could not be blindly changed to enforce checking the chain validity, as apparently it would create compatibility issues on some legitimate callers of that API that rely on that behavior, and Google opted (see this AOSP commit) to include an option to both of the behaviors, keeping the old "insecure" one for code that doesn't bother specifying what it wants, i.e. all existing code.
I haven't spotted any other commits that rely on this new behavior, but from my analysis it seems that the identified vulnerability vectors all go through the getPackageInfo(..., GET_SIGNATURES) PM API.
Therefore, so as not to cause the compatibility issues that Google seems to be cautious about, I have chosen to modify the behavior of JarTools.createChain() only when it's being used by the PM service. This will stop the possibility of using malicious apps impersonating NFC extensions (e.g. Google Wallet), Adobe web plugins, etc.
Additionally, and since Bluebox Security Scanner does a more direct check (in order not to require installing a malicious / proof-of-concept APK in order to then ask the PM service about its signatures), I also included code specific to this scanner so that it reports the bug as not present.


Source code
Available on Github



If you appreciated this fix, consider donating with Paypal.


Thanks!
 
Last edited:

Tungstwenty

Senior Member
Nov 1, 2011
1,830
4,512
Version history

1.1 (2014-08-10)
  • Support for Xposed Framework 2.2 (bridge v30) and above
  • Support for Gingerbread 2.3.3 and above
  • Reduced potential for compatibility issues by patching only the system services but not other apps that might be using a private API

1.0 (2014-07-31)
  • Initial version
 
Last edited:

defim

Senior Member
Feb 18, 2012
2,744
1,489
Motorola Defy
Nexus 7 (2013)
@Tungstwenty
After a quick look I think it is better to not fake return args for Bluebox if the rom is fixed and this module does nothing to fix it


Code:
	boolean romAlreadyFixed;
try {
XposedHelpers.findMethodExact("org.apache.harmony.security.utils.JarUtils", null, "createChain",
X509Certificate.class, X509Certificate[].class, boolean.class);
romAlreadyFixed = true;
}

...

if (romAlreadyFixed)
hookSuccessful = true;

}

...

	public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
if (!hookSuccessful) {
// Hooks not installed, don't report success to the activity nor the Bluebox scanner
return;
}
..
	// Change the reported "createChain" method signature to Bluebox Security Scanner so it marks the bug as fixed
 

Tungstwenty

Senior Member
Nov 1, 2011
1,830
4,512
After a quick look I think it is better to not fake return args for Bluebox if the rom is fixed and this module does nothing to fix it
I agree, and in fact it's not messing with Bluebox if the ROM is already fixed :)
Code:
if ([B]result.length == 2[/B]) {
	// Simulate that the method receives a 3rd parameter, boolean
	...
}
But your comment is perfectly valid since in fact it's not evident from the code; I'll change it to use 2 different booleans on init so it becomes clearer.
 
  • Like
Reactions: rahimali

liontari

Member
Jun 9, 2012
34
2
Does NOT work on my device (SGT P6800, ICS 4.0.4) :)

Gesendet von meinem GT-P6800 mit Tapatalk
 
Last edited:

liontari

Member
Jun 9, 2012
34
2
thx for your quick reaction! :)
Xposed framework: 2.6.1
After installation (reboot) my tab froze totally
I can't install 2.7.1. message: you need bridge v. 52 or higher. No other error report.
I really would impreciate your tipp/help.
Thx in advance!

Gesendet von meinem GT-P6800 mit Tapatalk

(Kernel: Linux version 3.0.15-P6800XXLQ2-CL834397 (se.infra@SEI-46) (gcc version 4.4.3 (GCC) ) #3 SMP PREEMPT Wed Jul 4 18:06:40 KST 2012
User-Agent: Mozilla/5.0 (Linux; U; Android 4.0.4; de-at; GT-P6800 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30)
 
Last edited:

Tungstwenty

Senior Member
Nov 1, 2011
1,830
4,512
Xposed framework: 2.6.1
After installation (reboot) my tab froze totally
I can't install 2.7.1. message: you need bridge v. 52 or higher. No other error report.
The minimum version of the bridge required for this module is 52.
If you have Xposed 2.6.1 installed and active, you should have version 54 (see this post) which is enough.

Please post a screenshot of the "Framework" tab of the installer (the one with the active/bundled numbers in green or red)
 

liontari

Member
Jun 9, 2012
34
2
9u5apyvu.jpg
apa6yta9.jpg
so sorry (ashamed) how to bring the screenshot in here?

Gesendet von meinem GT-P6800 mit Tapatalk

---------- Post added at 09:14 AM ---------- Previous post was at 09:09 AM ----------

Screenshot you wanted

Again sorry: Xposed 2.5.1...
When I tried to install 2.6, message after reboot: Xposed Installer stopped.
So what is to do?

Gesendet von meinem GT-P6800 mit Tapatalk
 
Last edited:

Tungstwenty

Senior Member
Nov 1, 2011
1,830
4,512
What version is reported on the About tab of the Xposed Installer?
anyway, you'll need to update it to a newer version, but I doubt that you indeed have version 2.6.1
 

liontari

Member
Jun 9, 2012
34
2
Please look above... I've made a mistake... sorry again

Gesendet von meinem GT-P6800 mit Tapatalk
 

Top Liked Posts

  • There are no posts matching your filters.
  • 110
    There is a new security vulnerability in town, this time labeled "Fake ID" (Google bug 13678484).

    The bug allows malicious apps to pretend to be signed by trusted providers and be loaded as extensions in several contexts such as NFC access, browser plugins and others.
    An excellent explanation can be found on this article by Jeff Forristal from Bluebox.


    Checking if you're vulnerable
    It appears to currently affect all devices, to a lesser or greater extent depending on which extensions each manufacturer included in their ROMs.
    You can use Bluebox Security Scanner to detect if your system is vulnerable.


    Installing the fix
    Fetch the package from the Xposed repository: http://repo.xposed.info/module/tungstwenty.xposed.fakeidfix (it is also available on Google play)
    Install as usual and make sure that you enable the module on the Xposed Installer and reboot.

    There are no configuration options. There is a simple information screen which can be accessed by tapping the entry on the Installer's module list (you won't see an icon for this on your launcher).


    Fix details
    For the tech savvy, here's an explanation of what this patch does.
    The JarTools class has an API for grabbing all signature certificatates present on an APK / jar. That API doesn't however check if *all* certificates form a valid chain, where each certificate is properly signed by the next one and so on, and not additional certificates are present that don't belong to that chain. It is therefore possible to insert additional certificates in that list, and *certain* callers of that API might be fooled if they assume that just because a certificate is on that list, the party to which it belongs did in fact sign or trust that code.
    This behavior could not be blindly changed to enforce checking the chain validity, as apparently it would create compatibility issues on some legitimate callers of that API that rely on that behavior, and Google opted (see this AOSP commit) to include an option to both of the behaviors, keeping the old "insecure" one for code that doesn't bother specifying what it wants, i.e. all existing code.
    I haven't spotted any other commits that rely on this new behavior, but from my analysis it seems that the identified vulnerability vectors all go through the getPackageInfo(..., GET_SIGNATURES) PM API.
    Therefore, so as not to cause the compatibility issues that Google seems to be cautious about, I have chosen to modify the behavior of JarTools.createChain() only when it's being used by the PM service. This will stop the possibility of using malicious apps impersonating NFC extensions (e.g. Google Wallet), Adobe web plugins, etc.
    Additionally, and since Bluebox Security Scanner does a more direct check (in order not to require installing a malicious / proof-of-concept APK in order to then ask the PM service about its signatures), I also included code specific to this scanner so that it reports the bug as not present.


    Source code
    Available on Github



    If you appreciated this fix, consider donating with Paypal.


    Thanks!
    11
    Version history

    1.1 (2014-08-10)
    • Support for Xposed Framework 2.2 (bridge v30) and above
    • Support for Gingerbread 2.3.3 and above
    • Reduced potential for compatibility issues by patching only the system services but not other apps that might be using a private API

    1.0 (2014-07-31)
    • Initial version
    9
    Any plans to release a Gingerbread version? I can confirm it works on Gingerbread as I lowered the minimum sdk on your apk and it installed fine. Bluebox Scanner shows FakeID patched.

    That's no evidence, as the module changes bluebox

    It only changes bluebox as long as the hooks on the system code that fetches the certificates without the chain validation were already hooked.

    Anyway, this detection based on the presence or not of the mentioned AOSP commit is not enough.
    It only provides the *alternate* API for strict validation; for the fix to be enforced it is still required that the appropriate places do use that stricter mode.

    I'm trying to setup a proof-of-concept APK including extra certificates to truly check if a system is properly filtering them out or not, regardless of the presence of this AOSP patch. I'll keep you posted.
    6
    Version 1.1 available

    An update is now available on the Xposed repo and also rolling out on Google Play.

    Check the 2nd post for the changelog - lower required version Xposed; GB support.