Skip to content
XSS Write-up Intermediate

Stored XSS via Markdown URL Attribute Injection — How I Earned

A Markdown rendering function built anchor tags by string interpolation without escaping double quotes in the href attribute, and DOMPurify was called on the input before the dangerous HTML was constructed, so it provided no protection. An attacker could store a URL containing a double quote to break out of the attribute and inject an event handler, leading to stored XSS for every visitor.

AnGrY Follow

Published on medium.com

A Markdown rendering function in a private bug bounty target’s React codebase was building <a> tags via string interpolation without escaping double-quote characters in the href attribute. Because DOMPurify was called before the dangerous HTML was constructed, it provided zero protection.

AnGrY, 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

The code interpolated user input into an HTML attribute without escaping double quotes, and the sanitizer was applied to the input before the dangerous HTML was built.

Impact

The stored payload was served to every visitor of the affected pages, and the same vulnerable component was used in six locations, though a CSP on staging blocked inline event handlers at runtime.

What the attacker needed

Ability to create or edit content; victim views the affected page

The fix

The program implemented output-side sanitization, building the HTML first and then passing it through DOMPurify with an allowlist of tags and attributes.

How it was found

  1. Create or edit a content item on the target platform.
  2. In the description field, enter a URL containing a double quote followed by an event handler.
  3. Publish or save the item.
  4. Navigate to the summary or detail page for that item.
  5. Inspect the DOM to confirm the injected attribute is present.

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.

When a website builds HTML by gluing strings together, it must escape special characters like double quotes. Here the code put a user-supplied URL directly inside an attribute without escaping, so a quote in the URL ended the attribute early and let the attacker add their own code. The sanitizer was run too early, on plain text, so it never saw the dangerous HTML.

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 AnGrY

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.