Skip to content
RCE Disclosed report Intermediate CVE-2022-41882

Desktop client can be tricked into opening/executing local files when clicking a nc://open/ link

The Nextcloud Desktop Client's handling of nc://open/ links passed a user-controlled file path to QDesktopServices::openUrl, which executes files rather than just opening them. An attacker who can upload a file to a shared instance could trick a victim into clicking a link that runs arbitrary code on the victim's machine.

lukasreschke Follow

Originally disclosed on HackerOne

Medium 6.6 View original
  • Triaged in 10 hours
  • Fixed in 17 days
  • Paid in 39 days
  • Disclosed after 4 months

Summary by the program

Security advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-3w86-rm38-8w63

The report

https://github.com/nextcloud/desktop/pull/4771 added support for "local edit", this feature is however implemented in an insecure way.

The code is calling into QDesktopServices::openUrl(QUrl::fromLocalFile(foundFiles.first())); and foundFiled.first() will be the path of the file specified via the deeplink:

C++
    // In case the VFS mode is enabled and a file is not yet hydrated, we must call QDesktopServices::openUrl from a separate thread, or, there will be a freeze.
    // To avoid searching for a specific folder and checking if the VFS is enabled - we just always call it from a separate thread.
    QtConcurrent::run([foundFiles] {
        QDesktopServices::openUrl(QUrl::fromLocalFile(foundFiles.first()));
    });

QDesktopServices::openUrl is however not suited for not trusted user input as it will also execute files directly.

Proof of concept

The following proof of concept was performed under Windows 10:

  1. In the web interface create a test.vbs file such as MsgBox "Hallo", VBOKOnly, "Ok".
  2. Open nc://open/[email protected]/test.vbs in the browser (adjust username and instance path)
  3. The VB Script will be executed and a popup will appear.

Note: This can also be exploited by a remote attacker if they upload a file to the same instance a user has access to.

Recommendations

There are several mitigation recommendations here:

  • Add a CSRF token to the nc://open/ link and have the client verify the token on request.
  • Ensure only safe file types can be opened using a local file viewer.

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

The Nextcloud Desktop Client in version 3.6.0 is vulnerable to a Remote Code Execution that can be exploited by anyone that is able to upload files to an instance the user has access to. In many cases this will be everyone due to public chats, files drop upload, etc.

Exploitation just requires the victim to visit a malicious web page (or click a link on an email or anything like that)

Attachments

Screenshot_2022-10-02_22.49.35.png
Screenshot_2022-10-02_22.49.35.png From the original on HackerOne

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

Impact

The vulnerability could lead to remote code execution on the victim's machine, requiring only that the victim visits a malicious page or clicks a link, and the attacker must be able to upload a file to an instance the victim can access.

What the attacker needed

Attacker can upload a file to a shared instance; victim clicks a crafted nc://open/ link

The fix

The report recommends adding a CSRF token to the nc://open/ link and restricting opening to safe file types, but does not state that a fix was applied.

How it was found

  1. Create a test.vbs file in the web interface.
  2. Open a crafted nc://open/ link in the browser.
  3. The VB Script executes and a popup appears.

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.

The desktop app had a feature that let links open local files. It used a system function that runs files instead of just showing them. So if someone uploaded a malicious file and sent a special link, clicking it could run that file on your computer.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

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.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.