--- name: android-apk-signing-integrity-janus description: Test APK signing schemes and the Janus vulnerability (CVE-2017-13156) — detect v1-only signing, confirm minSdk allows install on Android 5.0–8.0, and prepend DEX without breaking the v1 signature to inject code into a signed app. Tier 2. Use to assess integrity/update-hijack risk. Aligns to OWASP MASTG MASVS-RESILIENCE (MASTG-TEST-0224). --- # APK Signing & Integrity — Janus (CVE-2017-13156) v1-signature-only APKs on old Android let an attacker prepend a DEX and keep the signature valid — code injection into a "signed" app and update hijack. ## Trigger phrases `janus, cve-2017-13156, apk signing scheme, v1 signature, apksigner verify, dex prepend, apk integrity, update hijack` ## Execution gate (Tier 2 — modifies and installs a patched APK) 1. Ask: **"Lab/authorized to exploit on a test device?"** → if yes, run the full Janus PoC on an in-scope Android 5.0–8.0 device. Record the answer in `./.zazy/scope.md`. 2. If no: **"Run a dry scan (detection only)?"** → if yes, do only the signing-scheme + minSdk checks below; do NOT build or install a patched APK. ## Method 1. **Detection (always safe):** - `apksigner verify --verbose app.apk` — shows which schemes verify. **v1 verified, no v2/v3** = candidate. - `apktool -s d app.apk && grep minSdk app/apktool.yml` — confirm `minSdkVersion` allows install on a vulnerable OS (Android 5.0–8.0, unpatched). - Check for runtime signature/integrity enforcement in code (absence raises severity). 2. **Janus PoC (gated — authorized test devices only):** ```bash apktool -s d source.apk && mv source/classes.dex ./classes.dex python janus.py classes.dex target.apk patched.apk adb install -r patched.apk # installs/updates over the original ``` ## Modern / rare techniques - **[NEW/RARE] v1-only on modern minSdk:** some apps still ship v1-only; even where Janus install fails on patched OS, lack of v2/v3 + no runtime integrity is a finding. - **Update hijack:** a Janus-patched APK that updates over the original demonstrates the signed-update trust model is broken on vulnerable devices. ## Escalation / chaining Malicious code injection into a signed app → full app compromise / update hijack on vulnerable devices; pair with `android-root-antidebug-bypass` (no runtime integrity) and `android-manifest-analysis` (low minSdk). ## Backend & tooling Preferred Kali path (native Kali / WSL+Kali / Kali-SSH / Kali-MCP / HexStrike). Needs the user's in-scope Android 5.0–8.0 test device/emulator (adb) + Kali tooling (apksigner/apktool/janus.py). Windows-local last resort. See `zazy-orchestrator`. ## Verification (background, before reporting) Confirm `apksigner` shows v1-only AND (if exploited) the patched APK installs/updates over the original and runs the injected DEX, on an in-scope device. Reproduce before marking CONFIRMED; for dry-scan, report the signing/minSdk weakness without claiming exploitation. ## Evidence `apksigner verify` output, `minSdkVersion`, and (if gated-yes) the patched APK installing and executing injected code. Remediation: sign with v2/v3/v4; enforce `minSdk >= 24` where possible; runtime signature/integrity checks + Play Integrity.