- Edited
ryrona I have a question that is on-topic. Can someone explain what certificate pinning it is that can be bypassed? What is the consequences of this vulnerability for the end-user?
I can't explain every angle in full detail, but this problem is affecting the fdroidserver
(which is a standalone thing), where (in theory) there should be checks against get_first_signer_certificate
. In this exploit, fdroidserver
checks the multiple signing versions/methods (v1, v2, v3) in the wrong order (Android checks them in reverse, v3, v2, v1). Usually, get_first_signer_certificate
would be the basis for subsequent app submissions, which makes sense, since the original app dev is the first one to submit an app. With the reverse checking, v2 and v3 get ignored by froidserver
and you can sign APKs with whatever certificate you like, as long as it's signed via v1. This is especially problematic for 3rd party repos where apps get grouped in the F-Droid store as an identical APK basically, where you are just one tap away from installing a possibly completely different, malicious APK.
F-Droid devs acknowledged that there would be issues with their approach (instead of Obfusk's) and in a different issue, they wrote this (pasted as spoiler for better readability):
Apps in f-droid.org could only be affected if:
The metadata uses Binaries:
The app has a minSdkVersion of 24 or higher
The APK with the bad signature took the place of the good APK at the location the URL in Binaries: points to (e.g. attacker got GitHub/GitLab credentials of upstream developer).
There is a source code release to match the bad APK, e.g. included and tagged in the git repo.
There is a fdroiddata Builds: entry to build the bad APK.
The bad APK would have to be reproducible.
Additionally, to be an effective attack, it would require that:
Target does not already have the app installed (otherwise updates would fail at the Android signature check).
No one who had the app installed noticed that the update failed due to Android signature check.
Upstream dev does not notice bad APKs get posted, the source code pushes, or the new tag.
At best, this vulnerability lets the attacker act as if AllowedAPKSigningKeys was not set. Then the attacker would still have to compromise other visible things to get anywhere.
This does not affect signature copying method used when fdroid signatures copies files into fdroiddata. This is the preferred method for including reproducible builds with the highest level of security, but it is more work to maintain than the Binaries: approach.
binary repos
If a binary repo maintainer is not careful about where they get their APKs and relies completely on AllowedAPKSigningKeys to verify the APKs, then this is an important issue. The verification practices of the repo maintainer are not externally visible, so there is an element of trusting the maintainer. Somethings can be visible, like whether the repo includes GPG signatures on the APKs.
From the beginning, https://guardianproject.info/fdroid/repo/ relied on GPG signatures on every APK it downloaded and included. Those GPG signatures are part of the repo so others can verify them as well. AllowedAPKSigningKeys: was added because it is easy to use, and then we can dogfood it also. And hopefully, we can get AllowedAPKSigningKeys: good enough that the GPG signatures are no longer relevant. APK v3 Signatures are looking pretty good these days.!<
Overall, this is a very dangerous scenario which is confirmed by the devs, but earns nothing more than a shoulder shrug. Furthermore, it shifts responsibility to 3rd party repos (who would've seen that coming!).
Just irresponsible behavior and completely in line with what the project account wrote above.