mXSS: Potential XSS via noscript tags parsed by DOMParser APIs
Firefox's DOMParser API incorrectly decodes HTML entities inside <noscript> tags, turning safe HTML into executable HTML. An attacker could use this to perform mutation-based XSS (mXSS) by supplying crafted HTML that appears safe but becomes dangerous after parsing.
Originally disclosed on Mozilla
- Fixed in 23 months
- Paid in 23 months
- Disclosed after 23 months
Created attachment 9044953
fx_mxss_domparser_noscript.html
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0
Steps to reproduce:
Firefox decodes HTML entities inside <noscript> tags when it is parsed by DOMParser APIs.
For example:
`A <noscript> B </noscript> C <img src=x onerror=alert(1)> D </noscript> E`
This HTML will be:
`A <noscript> B </noscript> C <img src=x onerror=alert(1)> D </noscript> E`
You can check this behavior: https://vulnerabledoma.in/fx_mxss_domparser_noscript.html
By abusing this behavior, an attacker might do XSS attacks by changing safe HTML to XSS-able HTML.
This type of bug is known as "mXSS" (mutation-based XSS). For more information, see this paper: https://cure53.de/fp170.pdf
I attached the same HTML file as the above PoC.
Actual results:
Firefox's DOMParser API decodes HTML entities inside <noscript> tags.
Expected results:
Firefox's DOMParser API should not decode HTML entities inside <noscript> tags.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the DOMParser implementation does not follow the HTML specification for parsing <noscript> content, incorrectly decoding entities that should remain encoded.
Impact
An attacker could achieve XSS by supplying HTML that is safe before parsing but becomes executable after DOMParser processes it, though this requires the application to use DOMParser on attacker-controlled input.
What the attacker needed
Application uses DOMParser on user input; victim uses Firefox
The fix
The DOMParser API should be fixed to not decode HTML entities inside <noscript> tags, aligning with the HTML specification.
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 report has not been written yet. The Original tab links to the source.
When a browser parses HTML, it sometimes changes the structure. This bug shows that Firefox's DOMParser changes text inside a <noscript> tag in a way that can turn harmless-looking code into a script that runs. An attacker could trick a website into using DOMParser on malicious input, leading to script execution.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.