# 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**: `su` binary 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`), successful `fork` (sandbox violation), odd symlinks, suspicious DYLD images (`FridaGadget`, `CydiaSubstrate`), and jailbreak-evasion ObjC classes (Shadow). - **Anti-debug / anti-Frida**: `TracerPid` in `/proc/self/status`, `ptrace` self-attach, timing anomalies, the debuggable flag in release builds; for Frida — memory-map scans for agent artifacts, probing default Frida ports on `127.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/su` and tries `su` via `Runtime.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 [[raw/medium.com/33-cracks-in-the-armor-hacking-androgoat-to-learn-how-android-apps-rea-15949|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 `su` and 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's `sslpinning disable` and codeshare `anti-frida-detection.js`/`anti-root-bypass.js` are 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()` or `onCreate`, launch normally and attach after; or find the detection code in JADX and patch the smali (Objection `patchapk`, `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 - [[raw/appknox.com/a-comprehensive-guide-to-ios-jailbreak-detection-bypass-4020|A Comprehensive Guide to iOS Jailbreak Detection Bypass]] - [[raw/appknox.com/bypassing-ios-security-suite-jailbreak-detection-explained-and-tested-4021|Bypassing iOS Security Suite Jailbreak Detection]] - [[raw/kayssel.com/reversing-android-apps-bypassing-detection-like-a-pro-4917|Reversing Android Apps: Bypassing Detection Like a Pro]] - [[raw/pentest.bi0s.in/apkocalypse-l3ak-ctf-android-writeup-14985|Apkocalypse L3AK CTF Android writeup]] - [[raw/appsecnews.com/mobshield-open-source-rasp-for-android-and-ios-14594|MobShield: open-source RASP for Android and iOS]] - [[raw/meetcyber.net/android-bypassing-commercial-rasp-solutions-15125|Android — Bypassing Commercial RASP Solutions]] - [[raw/medium.com/frida-s-impact-on-mobile-security-and-how-to-fight-back-4328|Frida's Impact on Mobile Security and How to Fight Back]] - [[raw/proandroiddev.com/the-dead-keybox-economy-i-traced-a-pixel-10-keybox-back-to-its-source-14294|The Dead Keybox Economy]] - [[raw/promon.io/how-promon-found-hirudo-android-malware-by-accident-13500|How Promon found Hirudo Android malware]] - [[raw/appknox.com/root-jailbreak-detection-and-ssl-pinning-in-kmm-4916|Root/Jailbreak Detection and SSL Pinning in KMM]] - [[raw/medium.com/33-cracks-in-the-armor-hacking-androgoat-to-learn-how-android-apps-rea-15949|33 Cracks in the Armor: Hacking AndroGoat]]