--- name: android-insecure-storage description: Find sensitive data stored insecurely on-device — plaintext credentials, tokens, PII in shared_prefs, SQLite databases, files, external storage, and cache — via run-as/root, sqlite3, strings, and objection. Tier 1. Use after exercising app features. Aligns to OWASP MASTG MASVS-STORAGE (MASTG-TEST-0001). --- # Android Insecure Data Storage Trigger app features, then inspect every on-device storage location for plaintext secrets, tokens, and PII. ## Trigger phrases `insecure storage, shared_prefs, sqlite, databases, external storage, sdcard, cache, run-as, objection explore, plaintext token on device` ## Method 1. **Exercise the app first** — log in, store a card, save notes, etc., so secrets are actually written. 2. **Enumerate storage locations:** - `/data/data//shared_prefs/`, `/databases/`, `/files/`, `/cache/` - `/sdcard/Android/data//` and `/sdcard/` (external — world-readable pre-scoped-storage). 3. **Inspect (root or debuggable app via `run-as`):** - `adb shell run-as cat shared_prefs/*.xml` - `adb shell run-as ls databases/` - `adb pull /data/data//databases/app.db && sqlite3 app.db ".tables" ".dump"` - `strings` over files/cache for residual secrets. 4. **objection** (no manual rooting of paths): ``` objection -g explore android > env # dumps app dirs android > sqlite connect ``` 5. **Check insecure modes** — `MODE_WORLD_READABLE`/`MODE_WORLD_WRITABLE` (grep decompiled code for `openFileOutput(... MODE_WORLD`), and sensitive residue in external storage/cache. ## Modern / rare techniques - **EncryptedSharedPreferences / SQLCipher key recovery** — if "encrypted" storage is used but the key is derived in-app or keystore auth isn't bound, dump the key at runtime with Frida (`android-frida-objection-instrumentation`) and decrypt the store. - **Debuggable app = no root needed:** `android:debuggable="true"` lets `run-as` read private data on a stock device. - **External/scoped-storage residue:** check media/`Downloads` and app cache for exported secrets even when internal storage is clean. ## Escalation / chaining Plaintext tokens/session → account takeover (feed into `android-backend-api-testing`); encrypted-at-rest with recoverable key → `android-crypto-keystore`; combine with `android-backup-extraction` for a non-root path to the same data. ## Backend & tooling Preferred Kali path (native Kali / WSL+Kali / Kali-SSH / Kali-MCP / HexStrike). Needs the user's rooted device/emulator (or debuggable app) + Kali tooling (adb/sqlite3/objection/strings). Windows-local last resort. See `zazy-orchestrator`. ## Verification (background, before reporting) Reproduce the extraction independently (second pull, or a different storage path) and confirm the value is genuinely sensitive and live (e.g., the token still authenticates). Report true positives only. ## Evidence The file/DB path, the plaintext secret (redacted), the insecure mode if any, and proof it is usable. Remediation: EncryptedSharedPreferences/SQLCipher with keystore-backed keys; keep sensitive data off external storage; clear cache; never world-readable modes.