Summary
JustHTML Affected by Mutation XSS via Literal Text Serialization in Raw Text Elements (style/script)
Sanitized DOM trees can be unsafe to serialize when a custom policy allows raw-text elements such as <style> or <script>.
The issue affects DOM trees that are constructed or modified programmatically and then passed through sanitize_dom() with a policy that keeps these elements. Text nodes inside <style> and <script> are serialized literally, so attacker-controlled text containing the matching closing tag sequence can break out of the raw-text context and inject HTML into the serialized output.
The default sanitization policy is not affected because it drops the contents of style and script.
Details
The root cause is in HTML serialization of raw-text elements. In serialize.py, text children of script and style are emitted verbatim:
_LITERAL_TEXT_SERIALIZATION_ELEMENTS = frozenset({"script", "style"})
def _serialize_text_for_parent(text: str | None, parent_name: str | None) -> str:
if not text:
return ""
if parent_name in _LITERAL_TEXT_SERIALIZATION_ELEMENTS:
return text
return _escape_text(text)
Impact
Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is GHSA-QVC2-MG72-JJHX? GHSA-QVC2-MG72-JJHX is a medium-severity cross-site scripting (XSS) vulnerability in justhtml (pip), affecting versions <= 1.11.0. It is fixed in 1.12.0. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
- Which versions of justhtml are affected by GHSA-QVC2-MG72-JJHX? justhtml (pip) versions <= 1.11.0 is affected.
- Is there a fix for GHSA-QVC2-MG72-JJHX? Yes. GHSA-QVC2-MG72-JJHX is fixed in 1.12.0. Upgrade to this version or later.
- Is GHSA-QVC2-MG72-JJHX exploitable, and should I be worried? Whether GHSA-QVC2-MG72-JJHX is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-QVC2-MG72-JJHX is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-QVC2-MG72-JJHX? Upgrade
justhtmlto 1.12.0 or later.