Skip to content

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

  1. Server-side verification of everything the client asserts — this is the wall.
  2. Attestation verified on the server for high-risk calls.
  3. Detection and obfuscation as cost dials against opportunistic tampering.
  4. 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?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.