Lesson 13 of 13 · 12m
Hardening, Detection, and Attestation
R8 obfuscates names, root/jailbreak detection is a cost dial bypassable in one Frida session, and Play Integrity or App Attest only mean anything when verified on your server.
R8 is a minifier, not a moat
R8 — default since AGP 3.4 (2019) — shrinks, optimizes, and obfuscates: LoginManager becomes a.b, dead code disappears, mapping.txt records the rename table. It does not encrypt strings, does not remove logic, and does not survive jadx + patience. DexGuard (Guardsquare, paid) adds control-flow obfuscation, string encryption, and injected runtime checks — meaningful against static reading, still subordinate to dynamic instrumentation because the decrypt routine runs on the attacker's phone. iOS has no equivalent shipped toolchain — SwiftShield is long unmaintained — so "obfuscation" there means stripping symbols and not logging, not a product. FairPlay already encrypts App Store binaries at rest; every jailbroken device decrypts them on exec.
The honest framing: obfuscation raises the reading cost from minutes to hours. It is part of the cost dial, not the trust boundary.
Detection: what the checks buy
The standard list — su/magisk paths, frida-server port 27042, TracerPid in /proc/self/status, Debug.isDebuggerConnected(), signing-cert hash vs expected, getInstallSourceInfo() vs com.android.vending, Build.FINGERPRINT for goldfish/ranchu, ptrace self-attach to deny debuggers, Cydia.app/fork()/cydia:// on iOS — is real and all of it is hookable in one Java.perform session. RootBeer and IOSSecuritySuite package those checks for you; objection and Frida code-shares package their bypasses. Detection's actual value is sorting the adversaries: casual users and commodity scanners fail it and stop; determined operators bypass it and log. Measure it as cost imposed, not certainty gained — and never let a client-side check be the only enforcement of anything valuable, because the check itself runs inside the thing being checked.
Attestation: a signed verdict from the platform
Play Integrity API replaced SafetyNet Attestation — deprecated 2022, shut down January 2025. The flow: the app calls requestIntegrityToken with a nonce, Play returns a signed JWT, and your server decrypts/verifies it with Google's keys. The verdict fields that matter: appIntegrity.appRecognitionVerdict: "PLAY_RECOGNIZED" (this binary came from Play), deviceIntegrity's integrity values (MEETS_DEVICE_INTEGRITY, MEETS_STRONG_INTEGRITY — hardware-backed keystore attestation on supported devices, MEETS_VIRTUAL_INTEGRITY — emulator), and accountDetails.appLicensingVerdict: "LICENSED". Read it on the server. A verdict checked in client code is a boolean an instrumented attacker flips.
iOS's equivalent is App Attest (DCAppAttestService, iOS 14+): generate a key in the Secure Enclave, attest it once — Apple returns a CBOR attestation object binding the key to your app ID and device — then send an assertion per request. Server-side verification checks the attestation against Apple's App Attest root, the team ID, and the key, and the assertion's monotonic counter catches replay.
What attestation proves — and this is the part people oversell: that a request came from your unmodified binary running on a device the platform recognizes. It does not prove the user isn't hostile, that nothing is watching the screen, or that the account is honest. Rooted devices fail MEETS_STRONG_INTEGRITY — and Magisk modules exist to spoof the verdict anyway, because this is an arms race too. Use it to gate high-risk operations — account creation, payment, reward claims — not as a wall around everything.
The correct hierarchy
- Server-side verification of everything the client asserts — this is the wall.
- Attestation verified on the server for high-risk calls.
- Detection and obfuscation as cost dials against opportunistic tampering.
- Client-side checks as telemetry, not enforcement — they're lies the attacker controls.
Practice
Turn on R8, keep mapping.txt for retrace. Add the cheap detections — signature hash, installer provenance, debugger — and log their failures server-side rather than hard-failing the app (false positives on custom-ROM users are real). Gate the sensitive endpoints behind Play Integrity / App Attest verdicts checked on the server. Write the API as if the client is already compromised — because on any given device, it might be, and the attacker didn't need your permission.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
They Got Root on a Fully Patched Ivanti VPN and the Integrity Checker Said Everything Was Fine
Volexity caught an attacker chaining zero-days into unauthenticated root on an Ivanti Connect Secure appliance running the latest build. The payload never touched disk, commands rode in over the same HTTPS requests as the exploit, and Ivanti's Integrity Checker reported no modifications.
Gitea Shipped 21 CVEs in One Release and Eleven of Them Are the Same Bug
Gitea 28.3.0 landed November 1 with twenty-one CVE fixes. Read the list and a pattern jumps out: more than half are the same failure repeated across different route handlers, where a token scoped to public data gets handed private data anyway. That's not twenty-one mistakes.
php2shell: The PHP Bug That Fires Before Your Code Runs
Two critical PHP flaws landed October 21 and were in CISA's exploited-vulnerabilities catalog five days later. The 9.2 score isn't the part that should bother you. It's where the bug lives — it goes off while PHP is still assembling $_POST, before a single line of your application has run.
A Certificate Authority's Private Keys Were the Numbers 4, 56 and 66
Eight eMudhra intermediate CA keys turned out to be recoverable from their own public certificates. Not stolen — computable, because the key generation produced almost no entropy. A researcher pulled all eight in under a second and signed a message with each one to prove it.