fix: resolve meta-data resource refs, spoof SigningInfo history, hook binder entry points - #2
Open
aartzz wants to merge 1 commit into
Conversation
… hook binder entry points
Author
|
For anyone who wants to test this before it is reviewed: I published a signed test build of this branch on my fork. https://github.com/aartzz/XSpoofSignatures/releases/tag/v1.0.1-fix.1 It was built from the same source as this PR and verified on a Samsung Galaxy M32 (Android 13, One UI 5) with microG: Self-Check reports all signature checks as OK. Note that it is signed with a test key, not the upstream release key. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes three issues that prevented signature spoofing from working with microG (and similar consumers) on some ROMs:
Resource references in
<meta-data>are not resolvedfake-signatureandfake-signature-onlyare read withBundle#getString/getBoolean. When a manifest declares a resource reference, e.g. microG'sandroid:value="@string/fake_signature", the framework stores the integer resource ID in the bundle, not the value.getStringthen returnsnulland spoofing is silently skipped.The PR resolves integer meta-data values against the target application's resources (
AssetManager#addAssetPath+Resources#getValue, cached per APK path), supporting string, boolean, integer and fallback (coerced) values.The
SigningInfo/SigningDetailspath is not spoofed for single-signer packagesSigningInfo#getApkContentsSigners()returns a copy of the underlying array, so the previousorigSignatures[0] = sigearly-return path modified a throwaway array.SigningDetails#mSignatures/signatureswas never updated, andmPastSigningCertificates/pastSigningCertificateswas not updated either. Consumers that inspect the signing certificate history (e.g. microG'sPackageUtils#firstSignatureDigestBytes) therefore still saw the original certificate.The PR always writes the
SigningDetailssignature field and keeps the certificate history in sync when it is aSignature[].Only
ComputerEngine#generatePackageInfowas hookedOn some ROMs (observed on Samsung One UI 5 / Android 13, SM-M325FV) mutating the
PackageInfoproduced by the engine class is not enough: the object returned to callers over the binder is not the one modified there. The PR additionally hooks the binder entry points (IPackageManagerBaseon Android 13+,PackageManagerService$IPackageManagerImplon Android 12) andgetPackageInfo/getPackageInfoVersioned, with safe lookup so missing classes/methods are skipped on other versions.Testing
GmsCore/Phoneskydeclared withfake-signaturepointing at the Google certificate (38918a453d07199354f8b19af05ec6562ced5788).PackageManagerprobe run against both the binder interface and the app-levelPackageManagernow returns38918a453d07199354f8b19af05ec6562ced5788forsignatures[0],signingInfo.getApkContentsSigners()[0]andsigningInfo.getSigningCertificateHistory()[0].Підтримка підміни підпису) reports: system signature spoofing OK, microG Services correct signature OK, microG Companion / Play Store correct signature OK.Happy to adjust the approach (e.g. split into separate commits/PRs) if you prefer.