CSRF vulnerability in Nextcloud Desktop Client 3.6.1 on Windows when clicking malicious link
The Nextcloud Desktop Client on Windows failed to encode a token and a relative file path when constructing a request, allowing an attacker to craft a malicious deep link that, when clicked, sends an arbitrary POST request to the server. This could create a new admin user on the victim's Nextcloud instance.
Originally disclosed on HackerOne
- Triaged in 2 hours
- Fixed in 2 months
- Paid in 3 months
- Disclosed after 3 months
Summary by the program
Security advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-4gfv-xqpx-42qj
The report
Summary
It is possible to make a user send any POST request with an arbitrary body given they click on a malicious deep link. (e.g. in an email, chat link, etc)
This vulnerability was introduced in an attempt to fix #1720043. The patch however can be bypassed and also introduced a CSRF vulnerability.
Steps To Reproduce:
The following reproduction steps send a OCS API request to the /ocs/v1.php/cloud/users endpoint with the following post body: path=/.\&userid=hacker&password=h4ck3rPassw0Rd!&displayName=hacker&[email protected]&groups[]=admin&\..\.owncloudsync.log. If the victim is not an administrator, one would need to target another controller.
- Open the following deeplink on a Windows machine with the Nextcloud Desktop Client installed. Make sure to adjust the victim username and instance URL:
nc://open/[email protected]/.\&userid=hacker&password=h4ck3rPassw0Rd!&displayName=hacker&[email protected]&groups[]=admin&\..\.owncloudsync.log?token=../../../../../../../ocs/v1.php/cloud/users - Verify that a user called "hacker" is created on the instance and added to the admin group.
Root cause
The attempt to fix #1720043 was done with https://github.com/nextcloud/desktop/pull/5055 and introduced the following code:
const auto checkTokenForEditLocally = new SimpleApiJob(accountFound->account(), QStringLiteral("/ocs/v2.php/apps/files/api/v1/openlocaleditor/%1").arg(token));
checkTokenForEditLocally->setVerb(SimpleApiJob::Verb::Post);
checkTokenForEditLocally->setBody(QByteArray{"path=/"}.append(relPath.toUtf8()));
There are two vulnerabilities here that can be chained together:
- Token is not encoded:
tokenis concatenated directly into the URL and not properly encoded. Passing atokensuch like?token=../../../../../../../ocs/v1.php/cloud/userswill make the request therefore go to/ocs/v2.php/apps/files/api/v1/openlocaleditor/../../../../../../../ocs/v1.php/cloud/userswhich means/ocs/v1.php/cloud/users. - Relative file path is not encoded:
relPathis concatenated directly into the POST body and not properly encoded. Passing a path such as.\&userid=hacker&password=h4ck3rPassw0Rd!&displayName=hacker&[email protected]&groups[]=admin&\..\.owncloudsync.logwill therefore create several request POST parameters. (Note:./owncloudsync.logis a default file which I use here to ensure the file exists check earlier in the code works)
Supporting Material/References:
- Screenshot of the request: F1992646
- Screenshot of the created user: F1992654
Disclosure Policy
Please note that all bugs reported by Authentick GmbH will be publicly disclosed within 90 days of vendor notification. In extraordinary cases we may increase that upon request by the vendor.
Impact
It is possible to make a user send any POST request with an arbitrary body given they click on a malicious deep link. (e.g. in an email, chat link, etc)
Attachments


Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the token and relative file path were concatenated into the request URL and body without proper encoding, allowing path traversal and parameter injection.
What the attacker needed
Nextcloud Desktop Client on Windows; victim clicks a malicious deep link; victim is an administrator (or target another controller)
How it was found
- Open a crafted nc:// deep link on a Windows machine with the Nextcloud Desktop Client installed, adjusting the victim username and instance URL.
- Verify that a user called "hacker" is created on the instance and added to the admin group.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A deep link is a special URL that opens a desktop app instead of a web page. The app took parts of the link and put them directly into a web request without cleaning them up, so an attacker could hide extra instructions in the link. When the victim clicked it, the app sent a request that created a new admin account on their Nextcloud server.
What is CSRF?
Another site makes a signed-in user's browser perform an action they did not intend.