Hooks met vaste p-registers controleren niet of de methode een instance-methode is #85

Closed
opened 2026-10-14 13:46:19 +02:00 by midas · 1 comment
Owner

Severity: medium · Categorie: bytecode · Effort: S

Probleem

Verschillende hooks in obfuscated, door R8 bewerkte methodes gebruiken vaste p0, p1 en p2: Kubus content filters, Kubus Hide ads, forced update, Kubus Midas Settings, en Edition Hide ads (p1 als scratch). Dat klopt alleen zolang de methode een instance-methode is. De fingerprints pinnen geen accessFlags. AGENTS.md waarschuwt zelf dat R8 een methode static kan maken.

Waar

Bewijs

U3-1 (patches/src/main/kotlin/nl/midasvo/patches/kubus/contentfilters/ContentFilterPatches.kt)

ArticleComponentMapperFingerprint (obfuscated g20.a, no accessFlags): invoke-static/range {p1 .. p1}, ...shouldDropArticleComponent
HeaderBiddingWarmUpFingerprint (obfuscated c.a): const/16 p2, 0x0   // assumes p2 is the Prebid config
VersionCheckDecisionFingerprint (obfuscated ec4.a): const/16 p1, 0x0 ; return p1
DeepLinkRouterForwardFingerprint (parameters = listOf(), no accessFlags): invoke-static/range {p0 .. p0}

U2-5 (patches/src/main/kotlin/nl/midasvo/patches/edition/ads/HideAdsPatch.kt)

sget-object p1, Lkotlin/Unit;->INSTANCE:Lkotlin/Unit;
return-object p1   // p1 assumed = Context parameter

Impact

Wordt een methode static na een app-update, dan schuiven de argumentregisters één plek op. De hook assembleert dan niet, of hij leest of overschrijft stil het verkeerde argument. In het tweede geval geeft de patch Applied: en gedraagt de app zich fout.

Voorstel

Pin AccessFlags (zonder STATIC) in de fingerprints van deze hooks, of gooi een PatchException naast requireLocalRegisters als de methode static is. Leid het register waar mogelijk af met invokeArgumentRegister of uit het aantal parameters. Corrigeer het commentaar "p1 is the Context" in Edition Hide ads.

Acceptatiecriteria

  • Elke hook die pN op een obfuscated methode gebruikt, faalt bij het patchen met een duidelijke PatchException als de methode static is.
  • Applied: op de huidige Edition- en Kubus-APK's.

Code review @ 33e02db (2026-10-14) · findings: U3-1, U2-5

**Severity:** medium · **Categorie:** bytecode · **Effort:** S ## Probleem Verschillende hooks in obfuscated, door R8 bewerkte methodes gebruiken vaste `p0`, `p1` en `p2`: Kubus content filters, Kubus Hide ads, forced update, Kubus Midas Settings, en Edition Hide ads (`p1` als scratch). Dat klopt alleen zolang de methode een instance-methode is. De fingerprints pinnen geen `accessFlags`. AGENTS.md waarschuwt zelf dat R8 een methode static kan maken. ## Waar - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/contentfilters/ContentFilterPatches.kt#L46-59`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/contentfilters/ContentFilterPatches.kt#L46-L59) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/ads/HideAdsPatch.kt#L64-69`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/ads/HideAdsPatch.kt#L64-L69) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/forcedupdate/DisableForcedUpdatePatch.kt#L22-28`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/forcedupdate/DisableForcedUpdatePatch.kt#L22-L28) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/settings/MidasSettingsPatch.kt#L112-123`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/settings/MidasSettingsPatch.kt#L112-L123) - [`patches/src/main/kotlin/nl/midasvo/patches/kubus/settings/Fingerprints.kt#L60-70`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/kubus/settings/Fingerprints.kt#L60-L70) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/ads/HideAdsPatch.kt#L55-73`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/ads/HideAdsPatch.kt#L55-L73) - [`patches/src/main/kotlin/nl/midasvo/patches/edition/ads/Fingerprints.kt#L48-76`](https://git.midasvo.nl/midas/midas-patches/src/commit/33e02db957a78f2d5443326cdd107a612e7c21a7/patches/src/main/kotlin/nl/midasvo/patches/edition/ads/Fingerprints.kt#L48-L76) ## Bewijs _U3-1 (patches/src/main/kotlin/nl/midasvo/patches/kubus/contentfilters/ContentFilterPatches.kt)_ ```kotlin ArticleComponentMapperFingerprint (obfuscated g20.a, no accessFlags): invoke-static/range {p1 .. p1}, ...shouldDropArticleComponent HeaderBiddingWarmUpFingerprint (obfuscated c.a): const/16 p2, 0x0 // assumes p2 is the Prebid config VersionCheckDecisionFingerprint (obfuscated ec4.a): const/16 p1, 0x0 ; return p1 DeepLinkRouterForwardFingerprint (parameters = listOf(), no accessFlags): invoke-static/range {p0 .. p0} ``` _U2-5 (patches/src/main/kotlin/nl/midasvo/patches/edition/ads/HideAdsPatch.kt)_ ```kotlin sget-object p1, Lkotlin/Unit;->INSTANCE:Lkotlin/Unit; return-object p1 // p1 assumed = Context parameter ``` ## Impact Wordt een methode static na een app-update, dan schuiven de argumentregisters één plek op. De hook assembleert dan niet, of hij leest of overschrijft stil het verkeerde argument. In het tweede geval geeft de patch `Applied:` en gedraagt de app zich fout. ## Voorstel Pin `AccessFlags` (zonder `STATIC`) in de fingerprints van deze hooks, of gooi een `PatchException` naast `requireLocalRegisters` als de methode static is. Leid het register waar mogelijk af met `invokeArgumentRegister` of uit het aantal parameters. Corrigeer het commentaar "p1 is the Context" in Edition Hide ads. ## Acceptatiecriteria - [ ] Elke hook die `pN` op een obfuscated methode gebruikt, faalt bij het patchen met een duidelijke `PatchException` als de methode static is. - [ ] `Applied:` op de huidige Edition- en Kubus-APK's. _Code review @ 33e02db (2026-10-14) · findings: U3-1, U2-5_
Author
Owner

Opgelost in PR #120, gemerged in dev en uitgebracht in v1.10.0 (onderdeel van #105).

Opgelost in PR #120, gemerged in dev en uitgebracht in v1.10.0 (onderdeel van #105).
midas closed this issue 2026-10-17 21:22:41 +02:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
midas/midas-patches#85
No description provided.