In-depth lesson · Mutation XSS and sanitiser bypass
Tips for beginners
Every point the Mutation XSS and sanitiser bypass reports back under this heading, best-backed first, each with the reports it is seen in.
-
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
-
Use a systematic approach: fuzz the sanitiser with a wide range of HTML elements and attributes, and observe what survives. Tools like DOM Invader can help automate this. Pay special attention to attributes that can execute script, such as event handlers, and to elements that can load external resources.
Seen in 3 reports
-
Consider the context where the sanitised output is placed. If it is placed inside an attribute, inside a script block, or inside a style block, different parsing rules apply. Mutation XSS often arises when the context changes between sanitisation and rendering. Test each context separately.
Seen in 3 reports
-
When testing email clients or other applications that process HTML, consider how they handle CSS and embedded content. CSS escapes and url() values can be used to bypass filters. Test with encoded characters and observe if they are decoded after sanitisation.
Seen in 3 reports
-
Finally, always consider the user interaction required. Some payloads need a click or a paste. If the program only accepts zero-click XSS, focus on stored or reflected vectors that execute automatically. Clearly state the interaction required in your report.
Seen in 3 reports
-
Common mistakes include reporting a sanitiser bypass that does not lead to script execution, or reporting a payload that only works in a specific browser without noting that. Always verify in multiple browsers if possible, and ensure the impact is clear. Also, avoid using payloads that rely on user interaction unless the program accepts that.
Seen in 2 reports
-
If you find a bypass, try to minimise the payload and make it robust. Avoid relying on specific browser versions unless the program accepts that. Document the exact steps to reproduce, including the browser and version used, and the expected versus actual behaviour.
Seen in 2 reports
-
Do not ignore older or less common browsers. Some mutation XSS issues are specific to certain browsers or versions. If the program's scope includes them, test on Safari, Firefox, and Edge, as their parsing behaviours can differ.
-
Be aware of scope. Only test on programs that explicitly allow mutation XSS testing and on assets that are in scope. Do not test on third-party services or out-of-scope domains. If unsure, ask the program first.
Seen in 1 report