fix(playscan): correct the foregroundServiceType resource ID - #19
Merged
Conversation
The framework attribute ID table is the fallback used when aapt2 omits an attribute's name from the compiled string pool, which it routinely does. A wrong entry fails silently: the attribute never resolves, and every rule that reads it stops firing with no error. foregroundServiceType was recorded as 0x01010596. aapt2 assigns it 0x01010599, identically on android-34, -35 and -36. The consequence was that both foreground-service checks, which are CRITICAL because the app throws at startForeground() on Android 14+, silently reported nothing on any manifest that relied on the fallback. Verified on a real aapt2-linked manifest with the pool entry blanked: 0 findings before, 2 after. Every remaining ID in the table was read back from `aapt2 dump xmltree` rather than recalled, and TestFrameworkAttrIDsMatchAapt2 now pins all nine and fails on any unverified addition. The two networkSecurityConfig entries were both guesses and are removed; no rule reads that field. The unit fixture had encoded the same wrong ID, which is why the existing tests passed. It now uses the verified value.
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.
Found by building Android apps with the real toolchain and comparing against
aapt2 dump xmltree.The bug
frameworkAttrIDsis the fallback for resolving attribute names when aapt2 omits them from the compiled string pool, which it routinely does. A wrong entry fails silently: the attribute never resolves, and every rule reading it stops firing with no error.foregroundServiceTypewas recorded as0x01010596. aapt2 assigns it0x01010599, identically on android-34, -35 and -36.Both foreground-service checks are CRITICAL, because the app throws
SecurityExceptionatstartForeground()on Android 14+. On any manifest relying on the fallback, they reported nothing.Proof
A real aapt2-linked manifest with the
foregroundServiceTypepool entry blanked, forcing resolution through the resource map:Why tests didn't catch it
The unit fixture hand-encoded the same wrong ID, so the decoder and the fixture agreed with each other. Fixtures can only catch disagreements with themselves. Fixed to the verified value.
Hardening
Every remaining ID was read back from
aapt2 dump xmltreeon a manifest declaring each attribute, not recalled.TestFrameworkAttrIDsMatchAapt2pins all nine and fails on any addition that hasn't been verified the same way.The two
networkSecurityConfigentries were both guesses and are removed; no rule reads that field.Note
Medium Risk
Changes manifest decoding used for CRITICAL Play policy findings; the fix reduces false negatives but any remaining wrong ID would still fail silently until caught by the new tests.
Overview
Fixes silent mis-resolution of
android:foregroundServiceTypewhen aapt2 leaves the attribute name out of the compiled manifest string pool and playscan falls back toframeworkAttrIDs.Updates
foregroundServiceTypefrom0x01010596to the aapt2-verified0x01010599(same on API 34–36), aligns the hand-built AXML test fixture, and drops two unverifiednetworkSecurityConfigmap entries that no rule reads.Adds
TestFrameworkAttrIDsMatchAapt2to lock the nine aapt2-confirmed IDs (bidirectional: no missing or unverified table entries) andTestAttrNameFallsBackToResourceMapso empty pool + resource map still resolvesforegroundServiceType, with pool names winning when present.Reviewed by Cursor Bugbot for commit f4c9c24. Bugbot is set up for automated code reviews on this repo. Configure here.