# Android App Security
> The Android-specific attack surface: the app sandbox and its IPC (intents, exported components, ContentProviders), local storage, WebViews, native and dynamic code, and the platform mitigations (SELinux, Verified Boot, Play Integrity) that app and OS security test against.
## The sandbox and what breaks it
Each app gets its own UID and a private data directory; SELinux confines a normal app to the `untrusted_app` domain. Most Android app bugs are failures to respect that boundary at an IPC edge, not memory corruption. The canonical mistakes:
- **Exported components.** An `android:exported="true"` Activity/Service/Receiver (or one with an intent filter) is reachable by any installed app. Dangerous when it forwards attacker data to a privileged sink — see [[Mobile OAuth and Deep Link Attacks]] for intent redirection and deep-link abuse.
- **ContentProviders.** `exported="true"` + `grantUriPermissions` providers that build SQL from caller input are still exploitable by [[SQL Injection]] (Ostorlab's Yahoo Weather example) or leak/write files. GitHub Security Lab's AI taskflows found exported `MapActivity` in OsmAnd (10M+ installs) accepting `silent_import`/`replace` extras to plant tracking config.
- **FileProvider misconfig.** A library shipping `exported="true"` on an Activity plus root-scoped `<paths>` (`com.canhub:android-image-cropper`) gave any app an arbitrary-file-overwrite primitive in every consumer — the default was the vuln, not the integrator.
- **Dynamic code loading + path traversal** → RCE (Adobe Acrobat for Android, CVE-2021-40724 class).
- **Exported everything (AndroGoat).** One `exported="true"` attribute undid four gates: `adb shell am start` opened a PIN-protected Activity directly, `am startservice` triggered a download service, `am broadcast` was accepted with no sender check, and a custom scheme (`androgoat://vulnapp`) reached the same Activity. Default to `exported="false"`; if a component must be exported, gate it with a signature-level permission and check `getCallingUid()`/`getCallingPackage()` [[raw/medium.com/33-cracks-in-the-armor-hacking-androgoat-to-learn-how-android-apps-rea-15949|AndroGoat]].
## Local data exposure
- **Insecure storage.** Secrets in `SharedPreferences`, plaintext files, or logs. `allowBackup=true` can push "local" data to cloud/ADB backups — set `android:allowBackup="false"`. Insecure logging leaks secrets to `logcat` in plaintext (`grep` over a log stream), bypassing at-rest thinking.
- **EncryptedSharedPreferences is deprecated.** Jetpack Security Crypto was abandoned over Keystore inconsistencies across OEMs/versions; Google now steers to Jetpack DataStore + Google Tink (AEAD) with hardware-backed Keystore keys. Best practice remains: don't persist secrets at all, else encrypt before disk.
- **Clipboard.** Since Android 12 a toast warns when an app reads the clipboard; a 2025 technique hides that toast with no permission (Google rated it Moderate, Won't Fix), so copied passwords/2FA codes remain readable by the next app.
- **Keystore / biometrics.** `BiometricPrompt`, Credential Manager and hardware-backed Keystore are the correct primitives; client-side role/authZ checks are bypassable with [[Frida]].
- **AndroGoat storage and side channels** [[raw/medium.com/33-cracks-in-the-armor-hacking-androgoat-to-learn-how-android-apps-rea-15949|AndroGoat]]:
- Plaintext credentials in `shared_prefs/*.xml`, an unencrypted SQLite `users` table, `File.createTempFile()` leftovers in the data dir, and credentials on `/sdcard/Android/data/<pkg>/files/` that persist after uninstall.
- A score in `SharedPreferences` edited from 200 to 10,000: anything with business value stored client-side needs a MAC and server-side authority.
- Credential fields without `textNoSuggestions` (keyboard learning), credentials logged to `logcat`, an OTP copied to the global clipboard.
- Hardcoded promo code, OpenAI key and live AWS keys (listing real S3 buckets) — use a backend or short-lived scoped credentials (e.g. Cognito). See [[Hardcoded Secrets]].
- `android:debuggable="true"` in release: `adb forward tcp:7777 jdwp:<pid>` plus `jdb` gives live control. MD5-hashed PIN. An `isAdmin` boolean flipped with Frida. A biometric failure callback hooked into the success path; bind `BiometricPrompt` to a `CryptoObject` the server can verify.
## WebView, native and cross-platform
- **WebView** is the single largest Android bug source — its own page: [[WebView Vulnerabilities]] (`addJavascriptInterface` RCE, UXSS, file/content access, auth-header injection).
- **Cross-platform frameworks** widen the surface: Flutter ships its own TLS stack (see [[Certificate Pinning Bypass]]); .NET MAUI compiles shared C# that decompiles cleanly with ILSpy (Bishop Fox), so a single bug hits both platforms.
- **Native** `.so` code is reached via JNI; reverse with JADX (DEX→Java) + Ghidra. R8/ProGuard obfuscation raises cost but DEX decompiles far more cleanly than a stock iOS binary.
## Platform mitigations and their failure modes
- **Play Integrity / key attestation** is undermined by leaked **keyboxes** — genuine attestation private keys that forge Strong/Device verdicts for any app/device state (Promon found one in a repackaged Hirudo banking app; a survey of 551 public keyboxes found all 551 revoked). Google's move to Remote Key Provisioning (RKP) changes the economics. See [[Jailbreak and Root Detection Bypass]].
- **ADB** over on-device loopback enables LPE chains (CVE-2026-0073, adbd zero-click RCE); Google is considering restricting on-device ADB, which would also break Shizuku-style tooling.
- **OEM additions are a weak point.** OxygenOS `AtlasService`/OLC2 HAL chained `untrusted_app`→root on OnePlus 15 with no permissions (151+ devices patched). Firmware access-control analysis (Callix) found 819 vulnerable paths across 1,750 preinstalled apps.
- **Repackaging.** Attackers keep the package name, re-sign with their own key, add a DEX payload (SkyHook embeds a Frida agent; Hirudo hides accessibility services and strips `FLAG_SECURE`). Detect by package-name/signature mismatch (Promon's Koodous sweeps).
- **AI-assisted banking malware.** Bazuka and ArcticRAT pair local LLMs with fake overlays and ADB debugging to automate financial theft and target selection (partial article) [[raw/ismailtasdelen.medium.com/ai-powered-android-malware-inside-bazuka-and-arcticrat-15911|Ismail Tasdelen]].
## Testing
Decompile with `jadx`/`apktool`; scan with MobSF/`mobsfscan` or Fridexa (redacted evidence with file:line snapshots and generated Frida scripts, explicitly not runtime proof [[raw/medium.com/fridexa-building-an-evidence-first-android-vapt-platform-15948|Fridexa]]); instrument with [[Frida]]/Objection; intercept via [[Certificate Pinning Bypass]]; verify against MASVS/MASTG. Setup: rooted device or emulator (Magisk), `frida-server`, Burp/mitmproxy. See the hub for the full toolchain.
## Related
- [[Mobile Application Security]] · [[WebView Vulnerabilities]] · [[Mobile OAuth and Deep Link Attacks]] · [[iOS App Security]] · [[Jailbreak and Root Detection Bypass]] · [[Frida]] · [[Hardcoded Secrets]] · [[OWASP Mobile Top 10]]
## Sources
- [[raw/blog.ostorlab.co/android-sql-and-contentproviders-why-sql-injections-aren-t-dead-yet-4005|Android, SQL and ContentProviders]]
- [[raw/github.blog/how-we-found-24-android-vulnerabilities-using-our-open-source-ai-secur-12152|How we found 24 Android vulnerabilities with an AI agent]]
- [[raw/itis911.github.io/how-a-popular-android-library-silently-exposed-thousands-of-apps-to-ar-11548|Android image-cropper library Arbitrary File Overwrite]]
- [[raw/blog.includesecurity.com/encryptedsharedpreferences-is-dead-here-s-what-you-should-use-instead-11846|EncryptedSharedPreferences is Dead]]
- [[raw/medium.com/your-app-is-leaking-passwords-the-insecure-sharedpreferences-problem-15424|The Insecure SharedPreferences Problem]]
- [[raw/medium.com/android-pawned-day-2-insecure-logging-14593|Android Pawned — Day 2: Insecure Logging]]
- [[raw/privacyaffairs.com/android-clipboard-warning-bypass-apps-can-read-what-you-copy-14592|Android clipboard warning bypass]]
- [[raw/infosecwriteups.com/android-app-rce-via-dynamic-code-loading-11889|Android App RCE via Dynamic Code Loading]]
- [[raw/blog.nns.ee/getting-root-on-oneplus-15-from-an-untrusted-app-via-an-audio-debug-se-12102|Getting root on OnePlus 15 from an untrusted app]]
- [[raw/arxiv.org/beyond-sensitive-apis-detecting-access-control-flaws-in-android-firmwa-13971|Detecting access control flaws in Android firmware (Callix)]]
- [[raw/esecurityplanet.com/android-zero-click-rce-vulnerability-enables-remote-shell-access-7589|Android Zero-Click RCE in adbd (CVE-2026-0073)]]
- [[raw/bishopfox.com/unified-code-unified-risks-uncovering-vulnerabilities-in-net-maui-appl-12118|Uncovering Vulnerabilities in .NET MAUI Applications]]
- [[raw/httptoolkit.com/reverse-engineering-and-modifying-android-apps-with-jadx-and-frida-4918|Reverse engineering Android apps with JADX and Frida]]
- [[raw/medium.com/33-cracks-in-the-armor-hacking-androgoat-to-learn-how-android-apps-rea-15949|33 Cracks in the Armor: Hacking AndroGoat]]
- [[raw/ismailtasdelen.medium.com/ai-powered-android-malware-inside-bazuka-and-arcticrat-15911|AI-Powered Android Malware: Bazuka and ArcticRAT]]
- [[raw/medium.com/fridexa-building-an-evidence-first-android-vapt-platform-15948|Fridexa: evidence-first Android VAPT platform]]