Jailbreak and Root Detection Bypass
The resilience layer of mobile defense — root/jailbreak detection, anti-debug, anti-Frida, RASP, and hardware attestation — and why every client-side check on a device the attacker controls is defeatable, shifting real assurance to server-side attestation.
What the checks look for
These are MASVS-RESILIENCE (R) controls: they raise reversing cost, they don’t guarantee integrity.
- Android root:
subinary and root-manager packages, writable system paths, anomalous system properties, plus modern signals — Magisk’s abstract Unix socket, overlay/tmpfs mounts over system paths, Zygisk loader entries in/proc/self/maps, KernelSU traces, init-vs-app mount-namespace differences. - iOS jailbreak (e.g. iOS Security Suite’s
amIJailbroken(), 8 checks): suspicious URL schemes (sileo://), existence/openability of suspicious files, writable restricted dirs (/,/private), successfulfork(sandbox violation), odd symlinks, suspicious DYLD images (FridaGadget,CydiaSubstrate), and jailbreak-evasion ObjC classes (Shadow). - Anti-debug / anti-Frida:
TracerPidin/proc/self/status,ptraceself-attach, timing anomalies, the debuggable flag in release builds; for Frida — memory-map scans for agent artifacts, probing default Frida ports on127.0.0.1, thread-name checks, libc prologue-vs-baseline comparison to spot trampolines. - Emulator/automation: QEMU/Goldfish markers, sensor counts, Appium/UiAutomator presence.
- Naive examples (AndroGoat):
isRooted()checks for/system/bin/suand triessuviaRuntime.exec();isEmulator()looks for “generic” or “sdk” in device info. Both fall to one Frida return-value hook. Sturdier emulator checks use physical sensors, real-device performance quirks and hardware-backed Keystore status, with silent throttling instead of a visible block AndroGoat.
Why they’re bypassable
All of the above execute on hardware the attacker owns, so the result can be rewritten. Research consistently shows three tiers of effort:
- Hide from the check — Magisk DenyList/Zygisk hides
suand root paths; many apps that only scan for common indicators then stop caring. - Hook the check — Frida/Objection override the detection method’s return value (
isDeviceRooted()→false,amIJailbroken()→false). Objection’ssslpinning disableand codeshareanti-frida-detection.js/anti-root-bypass.jsare the quick path. Because Swift methods can’t be hooked by name, locate the function first with radare2/Ghidra, then hook. - Attach late / patch statically — if detection runs only in
Application.onCreate()/attachBaseContext()oronCreate, launch normally and attach after; or find the detection code in JADX and patch the smali (Objectionpatchapk,apk-mitm). CTF and real-app writeups follow exactly this (L3AK Apkocalypse: Frida-bypass root check, then Ghidra the native lib).
Defeating commercial RASP
RASP (freeRASP/Talsec, MobShield, Promon) moves checks into native code and emits weighted, scored signals rather than a boolean — e.g. MobShield: score = min(100, Σ weight×confidence/100) per threat, mapped to a severity; a single Frida-port hit (weight 85, confidence 95) ≈ 81 pts clears a critical threshold, while one weak su-path signal stays below warning. Bypass methodology (static-first): identify which System.load/loadLibrary calls belong to the RASP, map where the app layer talks to the native layer, then Smali-patch or replace native functions and correct the resulting execution flow; handle runtime string decryption and app-sealing as they appear. It’s an explicit arms race — both sides adapt continuously.
The attestation end-run (and how it breaks)
Because client checks fail, the industry pushes server-side attestation: Android Play Integrity / key attestation and Apple App Attest ask secure hardware (TEE/StrongBox, Secure Enclave) to vouch for the app and device state; a backend validates the certificate chain. This is stronger — but:
- Leaked keyboxes forge it. A keybox is the private attestation key + cert chain; whoever holds a valid one produces attestations for any key, app, or device state that validate against Google’s root — enough to defeat nearly anything relying on key attestation, including making a rooted phone look stock. Promon found a genuine, unrevoked keybox hardcoded in a repackaged Hirudo banking app; one survey checked 551 public keyboxes and all 551 were revoked (the public market is dead stock, but private leaks persist). Sources: weak provisioning storage, TEE/Keymaster compromise (Samsung TrustZone, USENIX 2022), and factory-key infrastructure leaks. Google’s Remote Key Provisioning (RKP) changes the economics by rotating/provisioning keys remotely.
- Boot-state nuance: root ≠ arbitrary attested boot state. A bootloader-unlocked Pixel reports ORANGE; a re-locked device with custom keys reports YELLOW. The gap is between what the device attests and what the relying service decides to trust.
Takeaway for testers and defenders
Treat detection/RASP as speed bumps for mass-market abuse and for the assessment itself (you’ll bypass them to test). Real controls: server-side authorization (Broken Access Control), hardware attestation with revocation checking and RKP, and not trusting any client verdict. See Certificate Pinning Bypass for the networking equivalent of the same lesson.
Related
- Mobile Application Security · Frida · Certificate Pinning Bypass · Android App Security · iOS App Security · OWASP Mobile Top 10 · Broken Access Control
Sources
- A Comprehensive Guide to iOS Jailbreak Detection Bypass · original
- Bypassing iOS Security Suite Jailbreak Detection · original
- Reversing Android Apps: Bypassing Detection Like a Pro · original
- Apkocalypse L3AK CTF Android writeup · original
- MobShield: open-source RASP for Android and iOS · original
- Android — Bypassing Commercial RASP Solutions · original
- Frida's Impact on Mobile Security and How to Fight Back · original
- The Dead Keybox Economy · original
- How Promon found Hirudo Android malware · original
- Root/Jailbreak Detection and SSL Pinning in KMM · original
- 33 Cracks in the Armor: Hacking AndroGoat · original