# Access to arbitrary file of the Nextcloud Android app from within the Nextcloud Android app

Nextcloud Android app's upload path check blocked /data/data/ but not /data/user/0/, letting a malicious app trick the client into uploading its private prefs to a public share.

- Payout: $250
- Severity: low
- Program: Nextcloud
- Found by: luchua
- Disclosed: 2022-09-11
- CVE: CVE-2022-39210
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1408692
- Library page: https://bugbountylibrary.com/r/h1%3A1408692
- Tags: area:mobile domain:mobile impact:data-leak kind:bounty platform:hackerone sev:low technique:incomplete-fix technique:source-review vuln:info-disclosure vuln:path-traversal

**Target:** Nextcloud Android client (com.nextcloud.client) file upload / FileUploader.java
**Root cause:** The fix only rejected storage paths starting with "/data/data/", but Android also exposes the same app-private directory via the alias "/data/user/0/", so the prefix check was bypassable.
**Steps:**
1. Install and log into Nextcloud Android client.
2. Create a directory and mark it shareable/public.
3. Install a POC app whose EvilActivity returns an Intent with data `file:///data/user/0/com.nextcloud.client/shared_prefs/com.nextcloud.client_preferences.xml`.
4. In the shareable directory tap '+', choose 'upload content from other apps', select the POC app.
5. The client uploads the private prefs file into the public share, leaking it.
**How found:** Reviewed the prior fix commit (PR 8433) that added a startsWith("/data/data/") check and recognized Android's alternate /data/user/0/ path alias bypasses the prefix filter.
**Exploitation:** A malicious co-installed app returns a file:// URI pointing at the Nextcloud client's private data via the /data/user/0/ alias. The victim user picks that app in the upload picker, and the Nextcloud client reads and uploads the file to a publicly shared folder, exposing secrets.
**Insight:** When auditing path-based denylists on Android, remember /data/data/<pkg> and /data/user/0/<pkg> are the same directory; prefix checks on one alias are trivially bypassed. Test every equivalent path form (symlinks, /data/user/N, /data/data) against the filter.

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

**EvilActivity returning private prefs file URI**

```
public class EvilActivity extends AppCompatActivity {
    private static final String LOG_TAG = EvilActivity.class.getName();

    final static String PRIVATE_URI = "file:///data/user/0/com.nextcloud.client/shared_prefs/com.nextcloud.client_preferences.xml";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Log.d("heen", "EvilActivity started!");
        setResult(-1, new Intent().setData(Uri.parse(PRIVATE_URI)));
        finish();
    }
}
```

