Stored XSS on scan.nextcloud.com
The scan results page inserted the scanned URL into the DOM as HTML without escaping, so a URL containing HTML markup would execute script. An attacker could trick a user into opening a crafted scan report and run JavaScript on a nextcloud.com subdomain.
- Triaged in 15 hours
- Fixed in 44 hours
- Disclosed after 19 months
The scan.nextcloud.com engine fetches a 'status.php' content in order to extract some version number as well as installed flavors.
While scanning a website, the following API-wise cinematic happens :
POST https://scan.nextcloud.com/api/queue (twice, gives the UUID)
GET https://scan.nextcloud.com/api/result/<UUID>
The first POST to /queue triggers a scan (/requeue works similarly), and the second request (GET) fetches a JSON describing the scan results.
While all the data fetched in the attacker-controlled "status.php" file are safely escaped with escapeHTML (stripping a lot of unwanted characters, - you might want to double check that \ is escaped as well.), the data.url isn't escaped, and is placed in a HTML DOM element as innerHTML

This means that if an URL contains valid HTML, it will be interpreted upon loading the XHR answer. A poc has been done, scanning for hack.pirate-server.com/heh<script>alert(1)
$ mkdir 'heh<script>alert(1)'
$ ln -s ../status.php heh\<script\>alert\(1\)/
POC : https://scan.nextcloud.com/results/166b377c-a24d-41b3-bcec-1ae57dd651c8
When loading the results, the <script> element is inserted, and an alert(1) pops :

poc demo :

end
Impact
An attacker - having tricked an user into accessing a trapped scan report - could gain arbitrary javascript execution in the context of scan.nextcloud.com, which is a subdomain of nextcloud.com.
While this might not be critical, maybe a Content-Security-Policy of another nextcloud.com domain blindly trusts *.nextcloud.com.
Which could mean the standard XSS consequences : impersonation, secret stealing, proxying traffic, drive-by malware download, etc. etc.
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
The application inserted the attacker-controlled URL into an element using innerHTML without escaping it, unlike other fields which were escaped.
Impact
An attacker who tricks a user into opening a trapped scan report could execute arbitrary JavaScript in the context of scan.nextcloud.com, potentially leading to impersonation, secret stealing, or malware download, especially if other nextcloud.com domains trust this subdomain.
What the attacker needed
Attacker can host a crafted status.php; victim opens a crafted scan report link
How it was found
- Create a directory whose name contains an HTML script tag and symlink status.php into it.
- Submit the URL of that directory to the scan queue API.
- Fetch the scan result using the returned UUID.
- Open the results page; the script tag in the URL is inserted and executes.
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.
When a website shows data from an untrusted source, it must treat it as text, not as code. Here the scanned site's address was inserted as raw HTML, so a specially crafted address could include a script tag. Opening the report then ran that script in the visitor's browser on the nextcloud.com domain.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.