Skip to content
XSS Write-up Advanced

Mutation XSS (mXSS)

The Bleach HTML sanitizer parsed certain HTML differently from browsers, allowing mutation XSS. An attacker could execute arbitrary JavaScript in sites using Bleach to sanitize untrusted content.

checkmarx.com

Published on checkmarx.com

As part of the beta testing phase that took place earlier this year for our recently launched Software Composition Analysis solution, CxSCA, the Checkmarx Security Research Team investigated Mozilla-Bleach, finding multiple concerning security vulnerabilities. Patches were released in mid-March 2020, with Checkmarx…

The author, on checkmarx.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 sanitizer and browser parsed certain HTML elements (noscript, svg/math with style) differently, so the sanitizer's cleaned output was re-interpreted by the browser as executable markup.

What the attacker needed

Application uses Bleach to sanitize untrusted HTML; attacker can submit HTML that reaches Bleach; victim views the sanitized content

The fix

The issues were fixed in Bleach versions 3.1.1 and 3.1.2.

How it was found

  1. Pass input containing a noscript tag with an attribute containing a style tag to Bleach.
  2. Observe that Bleach parses the noscript content as HTML and sanitizes the angle brackets in the attribute.
  3. Add another parsing context so that the sanitizer sees a style tag and stops parsing HTML, while the browser treats the style tag as text inside noscript.
  4. The browser then closes noscript and parses the remaining content as HTML, executing the injected markup.

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.

A sanitizer is a tool that cleans untrusted HTML so dangerous code cannot run. Here, the sanitizer and the browser disagreed about how to read some HTML, so the sanitizer thought the content was safe while the browser still ran a script. This is called mutation XSS.

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.