repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
android-physical-attacks.mdMarkdown150 lines10.5 KiBsource raw download

title: "Android Physical Attacks" section: "Mobile" sectionSlug: "mobile-pentesting" sourcePath: "src/mobile-pentesting/android-app-pentesting/android-physical-attacks.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/mobile-pentesting/android-app-pentesting/android-physical-attacks.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Android Physical Attacks#

BFU / AFU, FBE, and physical extraction attacks#

For mobile app pentests and seizure/forensics threat modeling, it is useful to separate the device into 2 states:[1]

Android credential path that matters during physical attacks#

Modern Android credential protection is not just the lockscreen UI:[2]

The important implication is that TEE compromise and lockscreen bypass are not always the same thing. On FBE devices, attackers often still need the credential-derived material used to decrypt the Synthetic Password.[1]

Useful artifact locations during rooted/physical analysis:[1]

BFU attack pattern on devices without a Secure Element#

On devices without a real Secure Element / StrongBox-backed Weaver path, the reusable pattern is:[1]

  1. Gain pre-OS code execution via Boot ROM bug or vendor mode such as MediaTek Download Mode / Qualcomm EDL.
  2. Patch the early boot chain so later stages no longer verify signatures.
  3. Load a modified Trusted OS / TEE and patch Gatekeeper to accept arbitrary credentials.
  4. Abuse Keymaster to recover intermediate key material.
  5. Extract the encrypted Synthetic Password and brute-force the credential offline.

That offline step converts the problem from device-side rate limiting into attacker-side compute:[1]

for candidate in candidates:
    stretched = scrypt(candidate, salt, params_from_spblob)
    applicationId = derive_application_id(stretched, other_material)
    plaintext = aes_gcm_decrypt(encrypted_synthetic_password, applicationId)
    if gcm_tag_valid(plaintext):
        return candidate

If you need the early-boot details for MediaTek devices, review:

Android Mediatek Secure Boot Bl2 Ext Bypass El3

Also note that public tooling such as MTKClient makes several MediaTek Boot ROM / download-mode workflows practical on affected chipsets.[6]

Biometric TA AuthToken forgery: root-to-CE bypass without patching Gatekeeper#

A second reusable pattern is to abuse biometric Trusted Applications (fingerprint / face TAs) that share the same AuthToken HMAC trust domain as Gatekeeper and Keymaster / KeyMint. On Android, a successful authenticator returns a signed hw_auth_token_t proving who authenticated, by which method, and when. If a biometric TA can be tricked into signing attacker-controlled data or leaking the shared per-boot HMAC key, Android root can be upgraded into PIN recovery and sometimes BFU CE decryption.[7]

Relevant AuthToken properties:[7]

Common exploitation patterns seen in vendor biometric TAs:[7]

  1. Signing oracle (GET_AUTH_OBJ-style bugs): a TA command accepts an arbitrary 69-byte buffer and simply HMAC-signs it, without checking that a fingerprint/face match actually happened.
  2. Biometric result oracle + verifier confusion: a TA emits a valid type-2 biometric token without a real match, and Keymaster incorrectly accepts it for operations that should require type-1 Gatekeeper authentication.
  3. Error-path secret leakage: HMAC verification failures print or return the shared 32-byte per-boot AuthToken HMAC key via TrustZone logs, shared memory, or even dmesg-reachable secure logs.
  4. TA memory disclosure / corruption: out-of-bounds reads or arbitrary-read primitives leak plaintext per-boot HMAC keys from heap / stack / BSS after defeating weak TA ASLR.

Once the attacker can mint a valid type-1 token (or a verifier incorrectly accepts type-2), the remaining CE attack looks very similar to the early-boot TEE-patching chain, but without modifying Gatekeeper itself:[7]

  1. Obtain Android root / kernel EL1 R/W.
  2. Invoke the biometric TA directly with libTEEC or an equivalent TEE client.
  3. Forge or request a signed Gatekeeper-typed AuthToken.
  4. Pass that token to Keymaster / KeyMint to decrypt the first-stage Synthetic Password blob.
  5. Brute-force the real PIN offline using the AES-GCM tag as a correctness oracle.

Minimal attacker view:[7]

at = forge_gatekeeper_authtoken()                  # type = 1, HMAC valid
spblob = read('/data/system_de/<uid>/spblob/...')
intermediate = keymaster_decrypt(at, spblob)

for pin in range(1_000_000):
    key = derive_synthetic_pw(intermediate, pin)
    if aes_gcm_decrypt(intermediate, key):
        return pin

Operational notes:[7]

StrongBox / Weaver changes the brute-force model#

If the device uses Weaver backed by a separate Secure Element / StrongBox, compromising Android or even the TEE is usually not enough to obtain an offline brute-force primitive:[1]

This is why short PINs are still weak, but a long alphanumeric password becomes much more resistant on properly implemented StrongBox devices.[1]

AFU USB exploitation: lockscreen is not the boundary anymore#

In AFU state, many forensic chains no longer attack the password. They attack the USB-reachable kernel attack surface exposed while the device is locked:[1]

A malicious peripheral emulator can present crafted descriptors/reports to reachable drivers, trigger memory corruption or information leaks, gain kernel code execution, and then read already-decrypted CE storage. At that point, the lockscreen is just UI and the attacker can pivot to full filesystem extraction, app databases, cached tokens, previews, and any application secrets that remain in memory.[1]

iOS parallel: USB policy bugs reopen AFU attack surface#

The same idea appears on iOS:

For defenders and app testers, the important lesson is simple: if the target device is AFU, assume filesystem-level compromise can expose app data unless the app adds its own cryptographic boundary.

References#