Skip to content
XSS Write-up Intermediate

Markup Impropose Sanitization

Many social coding and issue-tracking products allowed arbitrary class attributes on code and pre elements after Markdown sanitisation, so an attacker could reuse the site's own CSS rules and JavaScript event handlers bound by class name to forge page content or trigger actions on a victim's behalf. Some products had separate, more serious sanitisation failures that allowed full cross-site scripting with arbitrary JavaScript.

github.com

Published on github.com

History

The author, on github.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 sanitiser's allow-list permitted arbitrary class attributes on code and pre elements to support syntax highlighting, and in some products further transformations ran after sanitisation or the sanitiser ruleset was otherwise too loose.

Impact

Attackers could forge convincing page content and, where the site bound handlers by class name, trigger pre-existing JavaScript actions on a victim's behalf; in Bitbucket, YouTrack and Upsource this escalated to full cross-site scripting with arbitrary JavaScript, though Redmine's default setup had lower severity and Bitbucket had no CSP at the time.

What the attacker needed

Ability to post a comment or issue; victim views the comment; site allows HTML in Markdown

The fix

Sanitisation should be the final step, using a specialised sanitiser with a strict allow-list of tags and attributes, and a restrictive CSP should back it up.

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 site lets you write formatted comments, it must clean the result so no dangerous HTML survives. Here the cleaner was told to leave the class attribute alone on code blocks, and a class is just a label that the site's own styling and click handlers look for. By choosing the right labels, an attacker could make their comment look like a real site message or make a click run the site's own code.

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.