Lion Cipher Lab

Defeat a sanitizer with mutation XSS (mXSS), then fix it

Why it matters

Most teams treat an HTML sanitizer as a magic wand: run untrusted HTML through it, get back 'clean' HTML, drop that into the page, done. Mutation XSS is the reason that mental model quietly fails. A sanitizer works by PARSING the input into a DOM, walking that DOM, and stripping anything dangerous (script tags, on* event handlers, javascript: URLs). It then hands you back a STRING — and here is the trap: the browser has to PARSE THAT STRING AGAIN when you assign it to innerHTML. The sanitizer certified the first parse; the browser renders the second. The browser's HTML parser is not a pure…

What you'll learn

Steps in this lab

  1. Mutation XSS in one breath: the round-trip that betrays the sanitizer
  2. Build a naive sanitizer that trusts the round-trip
  3. See the round-trip mutate: CLEAN verdict, different rendered DOM
  4. Defeat a REAL sanitizer: pin a known-vulnerable DOMPurify and fire alert()
  5. Fix it: patch the sanitizer, stop the round-trip, add depth
  6. The judgment: sanitising is the fallback, not the plan

Open the full interactive lab →