In-depth lesson · technique
Mutation XSS and sanitiser bypass
What every disclosed Mutation XSS and sanitiser bypass report in the index teaches, put together: how it works, how it changed year by year, where it turns up, and things to try. Every point shows the reports it is seen in.
- reports cited in this lesson
- 107
- median public bounty
- $3,000
Learning Client-side in depth, step 4
Overview
What it is and why programs pay for it.
Mutation XSS is a class of sanitiser bypass where the browser's parser changes the structure of markup between the point it is sanitised and the point it is rendered. A sanitiser may clean one version of the DOM, but when that output is re-parsed, the browser can mutate it into executable markup. This happens because sanitisation often occurs on a serialised string or a parsed tree that does not match the final parse context. Programs care because it defeats the security control that is supposed to make user-generated HTML safe, leading to script execution in victims' browsers.
Mutation XSS usually leads to reflected or stored cross-site scripting, depending on where the sanitised content is later rendered. It is most often found in rich text editors, comment systems, email clients, wiki and markdown renderers, and any feature that accepts HTML and passes it through a sanitiser such as DOMPurify. Libraries and frameworks that sanitise on the client or server before inserting into the DOM are common targets, especially when custom elements, SVG, MathML, or CSS are involved.
The root cause is often a mismatch between the sanitiser's parsing model and the browser's actual parsing behaviour. This can involve namespace confusion, entity decoding order, custom element callbacks, or serialisation quirks. Because the browser re-parses sanitised output, any difference in how tags, attributes, or character references are handled can allow markup to mutate into an executable form. Hunters should focus on features where user input is sanitised and then re-inserted into the DOM, particularly where the sanitiser is configured with permissive options or where the output is placed in a different context than it was sanitised for.
Seen in these reports11
-
$750 -
Medium -
Medium
How it works
The mechanics, as the reports show them.
The attack begins with input that is accepted by a sanitiser but contains constructs that the browser will interpret differently on a second parse. For example, the sanitiser might allow certain tags or attributes that, when combined with browser parsing quirks, produce a different DOM tree. The attacker identifies a context where the sanitised output is later inserted into the page, such as via innerHTML or a rich text editor. The goal is to find markup that passes the sanitiser unchanged but mutates into script when the browser parses it again.
A common mechanism is namespace confusion. Sanitisers may process content in one namespace (such as SVG) and then the output is re-parsed in another (such as HTML), causing elements to be reinterpreted. For instance, an element that is inert in SVG context might become active in HTML context. Similarly, custom elements can fire callbacks during parsing before sanitisation runs, allowing side effects. These parsing differences are what make mutation XSS possible even when the sanitiser appears to remove dangerous tags.
Another mechanism involves entity decoding and serialisation. If the sanitiser checks for dangerous strings before the browser decodes HTML entities, an encoded payload can slip through and be decoded later. Likewise, if the sanitiser serialises the DOM and then the output is re-parsed, attributes or text that were safe in the DOM may become active markup. This is often seen with attributes like data-* that browsers can act on, or with CSS escapes that are decoded after sanitisation.
The step-by-step process for a hunter is to first identify a feature that sanitises user input and then renders it. Then, probe how the sanitiser handles edge cases: unusual tags, attributes, namespaces, and encoding. Look for differences between the sanitised output and what the browser actually renders. Tools like DOM invader or manual testing with crafted markup can help. Once a potential mutation is found, verify that script execution occurs in a realistic context, such as when a victim views the page or clicks a link.
What makes this possible is that sanitisation is often performed on a string or a DOM tree that does not match the final rendering context. Browsers are lenient and have complex parsing rules, so any discrepancy can be exploited. Additionally, sanitisers may have bugs in their allow-lists, may not account for browser-specific behaviours, or may be misconfigured. The complexity of modern web standards, including SVG, MathML, and CSS, provides many opportunities for such mismatches.
Seen in these reports17
-
$750 -
$5,000 High -
$3,000 High
Show 5 moreShow fewer
-
$2,400 Medium -
-
Medium -
Critical -
Medium
Year by year
8 yearsWhat each year's disclosed reports show, newest first. A year with few reports says less.
| 2015 | 3 |
|---|---|
| 2016 | 1 |
| 2017 | 5 |
| 2018 | 4 |
| 2019 | 6 |
| 2020 | 12 |
| 2021 | 7 |
| 2022 | 10 |
| 2023 | 6 |
| 2024 | 8 |
| 2025 | 16 |
| 2026 | 50 |
-
2026
New this year4
- Creating a MathML annotation-xml element with encoding set to text/html, appending it to the document, assigning innerHTML containing a style block with an img carrying an onerror handler fired the handler, a new technique.
- Setting a p element's innerHTML to markup with an is attribute holding a quote and an event handler, removing the is attribute, reading innerHTML again and re-parsing the output let the handler survive, a new bypass.
- Crafting nested elements that reset the namespace to null plus an iframe with a srcdoc script, passing it through an XML-aware sanitizer, showed the iframe was treated as inert and then became live, a new technique.
Kept working5
- A large group of Chromium reports shared the same shape: a CSSOM serialiser emitted a decoded identifier without re-escaping, breaking the round-trip invariant for sanitizers that read and re-inject CSS.
- Posting a comment containing a blockquote whose cite attribute hid a special newline character made wpautop() turn it into markup that broke out of the attribute.
Turned up less2
- The pattern of relying on a parsing behaviour change in a specific browser version to get script past a sanitiser, seen in 2017, was rarer in 2026 as reports focused on CSSOM serialisation and namespace confusion.
- The technique of using an XML entity in an SVG navigation icon upload to bypass a whitelist, seen in 2017, did not appear in the 2026 reports.
-
2025
New this year1
- Overwriting the file_type=lsif response with crafted JSON, refreshing, clicking the grey square and checking whether markup injected through the code navigation response ran script gadgets in data attributes was a new technique.
Kept working6
- Allowing math and style together, reflecting a parameter through the sanitize helper and sending crafted markup let script survive sanitisation.
- Allowing svg and style together, reflecting a parameter through the sanitize helper and sending crafted markup let script survive sanitisation.
-
2024
New this year1
- Inserting a newline in the DOCTYPE so the check that marks files unsafe failed to match and the file was served with inline disposition and a .xhtml filename was a new bypass.
Kept working3
- Sending a message with many unclosed p tags followed by an extra tag with an event handler bypassed the sanitiser by increasing the number of unclosed tags to fit larger tags.
- Setting a full name containing an unclosed anchor carrying gadget classes and an API transfer URL as its href made a victim click anywhere on a merge request page and sent an API PUT request on their behalf.
Earlier years5
Where it is found
3The features and places the reports found it in, most-reported first.
-
DOMPurify is a target for mutation XSS and custom element bypass research.
Seen in 4 reports
-
Mutation XSS is a general class of sanitiser bypass.
Seen in 2 reports
-
Mutation XSS has been found on a Mozilla support site.
Seen in 1 report
Technologies in these reports16
Root causes
39The mistakes in the code or configuration behind the reports.
-
The SVG sanitiser did not correctly handle XML entities, so the element and attribute whitelist was not applied to the resulting SVG content.
Seen in 2 reports
-
The cleanup that removes style when select is allowed was applied only to the per-call options tag list and not to the class-level allowed_tags list.
-
The sanitiser allowed the SVG use element to reference a data URI without inspecting the embedded SVG content, so an event handler inside it survived filtering.
Seen in 2 reports
-
The wpautop() regex used a pattern that stopped at the first closing angle bracket, including one inside an HTML comment placeholder, so a paragraph tag leaked into an attribute value.
-
Mention and reference linkification ran as a post-processing step on already-rendered HTML rather than during Markdown parsing, so it inserted markup inside existing attribute values.
Things to try
The most-reported tests in the largest contexts. Tick what you have tried; ticks stay in this browser and carry over to the full checklist. Test only what a program's scope allows.
ticked in this lesson
Frameworks and client-side rendering
of 3 ticked-
Seen in 1 report
-
Seen in 1 report
-
Seen in 1 report
Browser parsing and namespace mutation
of 3 ticked-
Seen in 1 report
-
Seen in 1 report
WAF and filter evasion
of 3 ticked-
Seen in 1 report
-
Seen in 1 report
-
Seen in 1 report
Bypasses and variations
8How reports got past filters, encoders and other defences.
-
Rely on a parsing behaviour change in a specific browser version to get script past a sanitiser that was written for older parsing.
Seen in 1 report
-
Use full-width or small-form Unicode characters that the back end converts to angle brackets, and chain MathML, xml:base and fake URLs to get past the filters.
Seen in 1 report
-
After the fix wrapped the input in an extra CDATA block, repeat the attack with the closing sequence doubled to escape the added wrapper.
Seen in 1 report
-
Use a path traversal after an allowed prefix to get past a startsWith allow-list on the use element's href.
Seen in 1 report
-
Use the data-disable-with attribute, which the sanitiser does not strip and which Rails-ujs turns into HTML on click, to get script or a form submission past the directive.
Seen in 1 report
Payouts
21 paidPublic bounties in US dollars, from the data. 21 of 181 reports show an amount.
- a quarter paid up to
- $2,000
- median
- $3,000
- three quarters paid up to
- $5,000
- highest
- $20k
One in ten paid reports was paid $10k or more.
| Severity | Reports | Paid | Median | Highest |
|---|---|---|---|---|
| Critical | 3 | 1 | $5,000 | $5,000 |
| High | 16 | 4 | $4,000 | $5,000 |
| Medium | 44 | 2 | $2,400 | $2,400 |
| Low | 11 | 1 | $337 | $337 |
| Unrated | 107 | 13 | $5,000 | $20k |
Highest-paid reports5
-
$20,000 -
$10,000 -
$10,000 -
$6,000 -
$5,083
Tips for beginners
13Advice for a first hunt, drawn from the reports.
-
Remember that some sanitisers are configured with options that allow dangerous tags. Check if the target allows tags like style, math, or svg, and if so, test combinations that might lead to mutation. Misconfigurations are common and can be easier to exploit.
Seen in 5 reports
-
Test with a variety of markup, including SVG, MathML, custom elements, and unusual attributes. Pay attention to how the sanitiser handles namespaces and encoding. Try to find discrepancies between the sanitised output and the rendered DOM. Simple probes like unclosed tags or encoded characters can reveal parsing differences.
Seen in 4 reports
-
Learn from public reports and known bypasses. Many mutation XSS issues are variations of previous findings. Study how DOMPurify and other sanitisers have been bypassed in the past, and adapt those techniques to your target. Keep up with browser parsing quirks and new HTML features.
Seen in 4 reports
-
Start by identifying features that accept HTML and sanitise it, such as comment boxes, rich text editors, wiki pages, and email clients. Look for places where the sanitised output is inserted into the DOM, especially via innerHTML or similar APIs. Use browser developer tools to inspect how the input is transformed.
Seen in 3 reports
-
When you find a potential bypass, demonstrate impact by showing script execution in a realistic scenario. For stored XSS, show that the payload executes when a victim views the page. For reflected XSS, craft a URL that triggers execution. Avoid reporting theoretical issues without a clear proof of concept.
Seen in 3 reports
Guides and techniques
The best explainers, cheat sheets and technique posts on Mutation XSS and sanitiser bypass, from around the web.
-
Escaping '<' and '>' in attributes – how it helps protect against mutation XSSExplains the HTML spec change escaping angle brackets in attributes and how it mitigates mutation XSS in sanitizers.
Explainer bughunters.google.com
-
How HTML Sanitizers Actually Work, and the Five Ways They BreakExplains how HTML sanitizers parse and filter markup and catalogues five common classes of bypass.
Technique kd-200.medium.com
-
The Canary Method: Finding Every Reflection Before You Fire a Single PayloadDescribes a method for mapping every user input reflection point before sending XSS payloads, saving time during testing.
Technique kd-200.medium.com
-
Dom-Explorer tool launched to reveal how browsers parse HTML and find mutated XSS vulnerabilitiesIntroduces Dom-Explorer, an open-source tool showing how browsers and sanitisers parse HTML to find mutation XSS.
yeswehack.com
-
Hunting for DOM-based XSS vulnerabilities: A complete guideExplains DOM XSS sources and sinks, discovery via static analysis and runtime interception, plus exploitation through common sinks.
Explainer intigriti.com
Keep learning
Where this lesson fits, and what to read next.
Learning paths
The whole class
Related techniques
How this is made: our model read every listed Mutation XSS and sanitiser bypass report in the index (our own summary where we have one, otherwise the title and the platform's label), listed the patterns, and merged them. Each point was kept only if the reports it cites exist, are listed and belong here; payouts are computed from the data, not written by the model. Read the originals before relying on a point. Generated 27 Nov 2026 from 107 reports. All Mutation XSS and sanitiser bypass reports.