--- name: android-secrets-hardcoded description: Hunt hardcoded secrets and cloud misconfig in APKs — API keys, tokens, crypto keys, Google AIza keys, Firebase DB URLs, S3/GCS buckets — with strings/grep/apkleaks/nuclei/MobSF, then test each live endpoint for unauthenticated access. Tier 1. Use after decompiling any APK. Aligns to OWASP MASTG. --- # Android Secrets, Hardcoded Keys & Cloud Misconfig Client apps leak credentials in code, resources, assets, and native libs. Find them, then prove each live secret reaches a backend. ## Trigger phrases `hardcoded secret, api key, apikey, firebase, aiza, apkleaks, token in apk, s3 bucket, gcs bucket, cloud creds, strings grep apk` ## Method 1. **Grep the whole package** (decompiled smali + Java + resources + assets): - `strings app.apk | grep -iE "password|api[_-]?key|secret|token|bearer|http"` - `grep -rniE "api_key|apikey|secret|aws|firebaseio|AIza|-----BEGIN" app_src/ app_java/` - Don't forget `res/values/strings.xml`, `BuildConfig`, `assets/`, and native libs (`strings lib/*/*.so` — see `android-native-lib-analysis`). 2. **Automate extraction:** `apkleaks -f app.apk` (URLs, keys, endpoints, regex hits); MobSF secret scan; `nuclei` with mobile/keys templates against recovered endpoints. 3. **Validate each secret is live** (don't report raw strings as findings): - Firebase open DB: `curl -s "https://.firebaseio.com/.json"` → 200 + data = world-readable (also test write). - Google `AIza` key → test against the API it unlocks (Maps/other) and check for package+signature restriction. - AWS/GCP creds → `aws sts get-caller-identity` / enumerate; S3/GCS bucket → test public list/read/write. 4. **Scope impact** — map what the live secret unlocks (paid API abuse, PII, full backend). ## Modern / rare techniques - **[RARE] Secrets in native `.so`** or packed DEX — moved there for "safety" but still recoverable via `strings`/Ghidra/Frida (chain `android-native-lib-analysis`). - **Firebase world-writable** (`PUT`/`PATCH` to `/.json`) is higher severity than read-only — always test write. - **Google API key restriction check:** an unrestricted `AIza` key billed to the client = direct financial abuse. ## Bypass / evasion If strings are obfuscated/encrypted at rest, hook the decrypt routine with Frida at runtime (`android-frida-objection-instrumentation`) and dump the cleartext secret from memory. ## Escalation / chaining Live key/bucket → `cloud-pentest`; recovered API endpoints → `android-backend-api-testing` / `api-security`; crypto keys → `android-crypto-keystore`. ## Backend & tooling Preferred Kali path (native Kali / WSL+Kali / Kali-SSH / Kali-MCP / HexStrike). Needs the user's device/emulator for pulling the APK + Kali tooling (apkleaks/nuclei/MobSF/strings). Route live endpoint tests through Burp if a Burp MCP is present. Windows-local last resort. See `zazy-orchestrator`. ## Verification (background, before reporting) Independently re-confirm every secret is live (authenticate to the service, or trigger the Firebase/bucket read) before marking CONFIRMED. A string that matches a regex but does not authenticate is not a finding. Use a second vantage/account where possible. ## Evidence The secret location (file + line, redacted value), the live request proving access (Firebase `.json` 200, authenticated API call, bucket listing), and scoped impact. Remediation: no secrets in client; short-lived server-issued tokens; lock Firebase/bucket rules; restrict API keys by package+signature.