Skip to content
XSS Write-up Intermediate

Hacking Swagger UI - 101

Swagger UI versions up to 3.25.0 use an outdated DomPurify library that fails to sanitise certain inputs from query parameters, allowing DOM XSS. An attacker could inject malicious YAML or JSON resources to execute scripts, potentially leading to account takeover, credential harvesting, or phishing.

medium.com

Published on medium.com

Hi readers, this write-up is a hands-on practical guide to hackingSwagger UI which leads to DOM XSS, Resource Injection, Account Takeovers, Credential Harvesting, Phishing and many other Attack vectors.I have provided all my research study resources below along with steps to reproduce and POCS.

RivuDon, on medium.com

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

Root cause

Likely the outdated DomPurify library fails to sanitise certain inputs from query parameters, allowing script injection.

Impact

An attacker could execute scripts to steal session cookies leading to account takeover, or inject fake login pages for credential harvesting and phishing; however, the account takeover is described as theoretical and the resource injection in the API field is low severity.

What the attacker needed

Victim visits a crafted URL; Swagger UI version 0.0.0 to 3.25.0; attacker hosts a malicious YAML file

How it was found

  1. Find a Swagger UI instance page using Google dorks or nuclei templates.
  2. Append a query parameter such as ?url= to the URL.
  3. Add a payload URL pointing to a malicious YAML file to the parameter.
  4. If a pop-up appears, DOM XSS is confirmed; otherwise, resource injection may still be possible.
  5. For resource injection, use payloads that create a fake login page or phishing hyperlink.
  6. If an input field and explore button exist, directly enter the payload and click explore.

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 helps developers test APIs in their browser. The problem is that it doesn't properly clean up some input from the web address, so an attacker can trick it into running harmful code. This could let an attacker steal login information or show fake login pages.

What is XSS?

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

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.