JustHTML Affected by Mutation XSS via Literal Text Serialization in Raw Text Elements (style/script)
Key facts
- Attack vector
- —
- Privileges required
- —
- User interaction
- —
- Attack complexity
- —
- Impact type
- Cross-site scripting
- Confidentiality · integrity · availability
- —
- Fix status
- Fixed
No CVSS vector from any source. Fix status from GitHub. Impact type from CWE-79.
Summary
## 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: ```python _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)
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | justhtml (PyPI) | before 1.12.0 | 1.12.0 | Patch available | GHSA-qvc2-mg72-jjhx |
- justhtml (PyPI) Vendor— Affected before 1.12.0 Fixed in 1.12.0 Patch available GHSA-qvc2-mg72-jjhx
Remediation
- Fix · GHSA-qvc2-mg72-jjhx justhtml (PyPI) Fixed in 1.12.0 Advisory →
Timeline
- 2026-10-03 Threatist record created from GHSA-qvc2-mg72-jjhx
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences