Hacking SwaggerUI from XSS to account takeovers
Swagger UI versions 3.14.1 to 3.38.0 used an outdated DomPurify library that could be bypassed to achieve DOM XSS via query parameters. An attacker could execute JavaScript in the context of the Swagger UI page, potentially leading to account takeover by stealing tokens.
blog.vidocsecurity.com
Published on blog.vidocsecurity.com
The most cyber-capable open model, for defenders. Try now >>
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could execute arbitrary JavaScript in the context of the Swagger UI page, potentially leading to account takeover by stealing authentication tokens, though some instances may be protected by CSP or other defences.
What the attacker needed
Victim clicks a link; Swagger UI version 3.14.1 to 3.38.0; attacker hosts malicious spec
The fix
The vulnerability was fixed in Swagger UI version 3.38.0 and later; upgrading to the latest version (^4.13.0) or updating the DomPurify package resolves it.
How it was found
- Identify a Swagger UI instance with version between 3.14.1 and 3.38.0.
- Craft a malicious API specification file containing a DomPurify bypass payload in a description field.
- Host the specification file on an attacker-controlled server.
- Construct a URL to the Swagger UI with the configUrl or url parameter pointing to the malicious file.
- Send the URL to a victim; when visited, the payload executes in the context of the Swagger UI page.
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 write-up has not been written yet. The Original tab links to the source.
Swagger UI is a tool that displays API documentation. It used an old version of a security filter called DomPurify that had a flaw, allowing attackers to inject malicious JavaScript through the URL. This could let them steal login tokens or take over accounts.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.