Switch to semantic resources.arsc comparison in apkdiff reproducible script#14828
Closed
BarbossHack wants to merge 1 commit into
Closed
Switch to semantic resources.arsc comparison in apkdiff reproducible script#14828BarbossHack wants to merge 1 commit into
BarbossHack wants to merge 1 commit into
Conversation
3 tasks
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.
Contributor checklist
Fixes #1234syntaxDescription
Context
Currently, apkdiff relies on a binary-level comparison of the resources.arsc file using Androguard. While this worked historically, it has become increasingly brittle. The Google Play Store's post-processing may modifies the internal structure of the resource table (reordering string pools, modifying header sizes, and shifting data offsets) without changing the actual resource content.
Problem
These structural optimizations trigger massive, "false positive" diffs in apkdiff. We are currently seeing errors like ARSCResTypeSpec/ARSCResTableEntry/ARSCHeader inconsistencies (see #14809), which are artifacts of binary repackaging rather than actual application discrepancies. Attempting to filter these individual binary fields using Androguard is unsustainable.
Also, currently apkdiff has 2 flaws in its resources.arsc comparison:
Signal-Android/reproducible-builds/apkdiff/apkdiff.py
Line 300 in 4f0f093
Signal-Android/reproducible-builds/apkdiff/apkdiff.py
Line 267 in 4f0f093
Solution
Instead of comparing the binary structure, this PR proposes moving to a semantic comparison using
aapt2 dump resources. By using aapt2 (the official Android build tool), we verify the resolved values of the resources. This method is completely immune to the structural optimizations performed by the Play Store, as aapt2 parses the logical content rather than the raw file layout.We are still verifying content integrity. If a malicious actor modified a string in the resource table, aapt2 dump would catch it. The only thing we are ignoring is the 'the storage layout'.
Note that androguard is still needed to parse other binary XML files. I've updated it to v4.1.4 as explained here #14817 (comment)