Skip to content
XSS Write-up Beginner

I Found DOM-Based XSS & HTML Injection in Swagger UI

A Swagger UI instance on a dashboard subdomain accepted a user-controlled configUrl parameter that loaded an attacker-hosted Swagger JSON, allowing a fake login form for phishing and a DOM-based XSS payload. An attacker could craft a link that renders attacker content inside the trusted page, potentially stealing credentials or tokens.

medium.com

Published on medium.com

In this write-up, I’ll share how a simple recon flow led to discovering DOM-Based XSS and HTML Injection in a Swagger-UI .

0xmrX, 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 Swagger UI page read the configUrl (and url) query parameter and loaded remote configuration without restricting it to trusted origins, so attacker-controlled content was rendered in the page's origin.

Impact

An attacker could host a malicious link that shows a fake login form for credential phishing or runs script in the page's origin, potentially reading tokens from localStorage; the report does not show a real victim being affected.

What the attacker needed

Victim clicks an attacker-crafted link; Swagger UI reachable publicly

How it was found

  1. Enumerate subdomains and probe live hosts to find the dashboard host.
  2. Fuzz directories and endpoints to discover the Swagger UI path.
  3. Open the Swagger UI page and supply a configUrl pointing to an attacker-hosted Swagger JSON.
  4. Observe a custom login form rendered for phishing, and a script payload executing for DOM-based 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 write-up has not been written yet. The Original tab links to the source.

Swagger UI is a page that displays API documentation. This page let a visitor's link choose which configuration file it loaded, so an attacker could point it at their own file. That file could draw a fake login box or run script in the site's own page, which is dangerous because users trust that page.

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.