MASTG-DEMO-0123: Exfiltration of Private Files via FileProvider URI Grant Oversharing
Download MASTG-DEMO-0123 APK Open MASTG-DEMO-0123 Folder Build MASTG-DEMO-0123 APK
Sample¶
This demo uses the same victim app as Oversharing via FileProvider with Unrestricted Path Configuration. The victim's ShareReportActivity is an exported activity that accepts a caller-supplied file_name parameter, calls FileProvider.getUriForFile() with the requested filename, and returns the resulting content:// URI to the caller via FLAG_GRANT_READ_URI_PERMISSION.
Because file_paths.xml declares path=".", the FileProvider will accept any file under filesDir — not just the intended reports/ subdirectory. The attacker app below (org.owasp.mastestapp.attacker.provider) exploits this by passing session_token.txt as the file_name parameter and reading the returned URI content.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
Steps¶
- Install the victim app ( Oversharing via FileProvider with Unrestricted Path Configuration) using Installing Apps and tap Start to populate
filesDir. - Build and install the attacker APK (
MastgTest.kt,AndroidManifest.xml) using Installing Apps. - Tap Start in the attacker app to launch the attack.
- Run
run.shto capture the exfiltrated content from logcat.
| run.sh | |
|---|---|
1 2 3 | |
Observation¶
The attacker app displays a dialog showing the exfiltrated content. The same value is captured in logcat by run.sh.
| output.txt | |
|---|---|
1 2 | |
Evaluation¶
The test case fails because the attacker app successfully reads session_token.txt from the victim app's private storage via a URI grant from ShareReportActivity.
The token sess_7f3a9b1e4d2c8f0a5e6b3c1d9f4a2e7b visible in the logcat output was written by the victim app to filesDir/session_token.txt. The FileProvider.getUriForFile() call in ShareReportActivity accepts this path because file_paths.xml uses path=".", making the entire filesDir accessible — not just the intended reports/ subdirectory.
This confirms the security relevance required by the "Further Validation Required" section in References to Oversharing of File-Based Content Providers. FileProvider.getUriForFile() is called with an attacker-controlled file_name parameter, derived directly from the intent extras, and the app performs no validation before granting the resulting URI to the caller.