fix: harden smali hooks against branch targets and register limits #67
No reviewers
Labels
No labels
area/architecture
area/build-ci
area/bytecode
area/code-quality
area/docs
area/extension
area/fingerprint
area/security
area/tests
Bug report
Feature request
review
sev/low
sev/medium
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
midas/midas-patches!67
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-59-harden-smali-hooks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #59.
Changes
addInstructionsAtControlFlowLabel(shared/util/Instructions.kt): the hook goes in at the label of the instruction it precedes, so agoto/if-*to a return/invoke no longer skips it. It re-adds the instruction after itself, inserts the hook in between and removes the original location; dexlib2 moves its labels and debug items to the first hook instruction. Used at all sites from the issue: Edition review prompts and onboardingisSuppressed, theVideoProductionconstructors, KubusArticleDetailResponse.<init>, the toolbarsetValuecall andgetSections.const/4 pNbecomesconst/16, invokes on parameter or derived registers become/range, andinstance-of/iget-objectcopy into a checked scratch register first (move-object/from16 v0, pN).requireLocalRegistersnow takes acount: EditionnavigateToUrlneeds two scratch registers for{p0, p2}. The Kubus deep link hook now passes only the Activity, andProfileMenuPatch.handleDeepLink(Activity)reads the intent itself.invokeArgumentRegisterderives the register from the call'sMethodReference: the parameter index, +1 forthisunless it isinvoke-static, wide types counted, and both the 35c and the range form. Edition Markdown uses it foraddShareAction's list, and Kubus Markdown forsetValue's argument.Verification
gradlew buildAndroidsucceeds.scripts/check-patches.shprintsok(every patch applied) for AD, Trouw, Het Parool, BD, BN DeStem, De Stentor, ED, PZC, Tubantia (XAPKs), Volkskrant 7.52.0 and Videoland 1.115.2 (base APK). De Gelderlander 9.21.1: Morphe Desktoppatchapplied every patch..lineon the hook, and use the range form.🤖 Generated with Claude Code