GHSA-qvc2-mg72-jjhx: JustHTML Affected by Mutation XSS via Literal Text Serialization in Raw Text Elements (style/script)
Summary Sanitized DOM trees can be unsafe to serialize when a custom policy allows raw-text elements such as or . The issue affects DOM trees that are constructed or modified programmatically and then passed through sanitizedom() with a policy that keeps these elements.
Published Mar 18, 2026
Affected packages
justhtml
- Ecosystem
- PyPI
- Affected
- <= 1.11.0
- Fixed in
- 1.12.0
- Check
pip show justhtml
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
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)Credited to offset.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More PyPI vulnerabilities
All PyPI entriesGHSA-jf6w-2mvx-633j
justhtml: to_markdown() code-span blank-line breakout enables XSS
medium6.1Jun 25, 2026GHSA-r8cj-3554-33mr
justhtml introduces denial-of-service hardening
lowMay 8, 2026GHSA-vrx2-77f2-ww34
justhtml has sanitization bypass in custom policies and programmatic DOM
medium6.0Apr 22, 2026GHSA-4p64-v8f5-r2gx
Multiple security fixes in justhtml
low1.3Apr 14, 2026GHSA-c9vm-hv86-f23r
justhtml includes multiple security fixes
mediumApr 10, 2026GHSA-r758-8hxw-4845
justhtml: Mutation XSS with custom foreign-namespace sanitization policies
low2.1Apr 8, 2026
