Skip to content
XSS Write-up Intermediate

Swagger UI HTML Injection — From “No XSS” to $450 Bounty

An exposed Swagger UI accepted an external URL for its OpenAPI spec without domain allowlisting, letting an attacker control the rendered page and inject arbitrary HTML under the legitimate origin. Although DOMPurify blocked script execution, the HTML injection enabled credential phishing via a fake login form and an open redirect through the OAuth2 Authorize button.

abdelaalx2000 Follow

Published on abdelaalx2000.medium.com

A developer-facing data annotation platform on a private bug bounty program. Standard recon surfaced an exposed Swagger UI at /apidocs/, which immediately caught my attention.

Mohamed Adel, on abdelaalx2000.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's ?url= parameter accepted any external URL without domain allowlisting, allowing an attacker to supply a malicious OpenAPI spec that injected HTML into the page.

Impact

An attacker could render a fake login form under the trusted domain to phish credentials, or redirect users to an attacker-controlled domain via the OAuth2 Authorize button, though JavaScript execution was blocked by DOMPurify.

What the attacker needed

Victim clicks a crafted link; attacker hosts a malicious OpenAPI spec

The fix

The Swagger UI should restrict the ?url= parameter to an allowlist of trusted domains or disable external spec loading.

How it was found

  1. Find the exposed Swagger UI at /apidocs/.
  2. Supply an attacker-controlled URL via the ?url= parameter.
  3. Serve a malicious OpenAPI spec that injects raw HTML into the rendered page.
  4. Observe arbitrary HTML rendered under the legitimate target origin.

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, and it can load that documentation from a web address you give it. The site did not check which addresses were allowed, so an attacker could point it at their own page and make the site show attacker-controlled content. Even without running JavaScript, this let the attacker show a fake login form on the real company domain, which is dangerous for phishing.

What is XSS?

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

More by abdelaalx2000

View all

1 more disclosed report, best first.

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.