Advisory

GHSA-qvc2-mg72-jjhx

Also known as: CVE-2026-8630

Summary

JustHTML Affected by Mutation XSS via Literal Text Serialization in Raw Text Elements (style/script)

Details

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)

Severity

Medium Basis: The source's own band: MODERATE

Dates

Published
2026-03-18 20:19 UTC
Modified
2026-08-24 03:56 UTC

Affected packages and fixes

justhtml

PyPI · All systems

Affected

  • introduced 0, fixed 1.12.0 (ecosystem)

Fixed versions

1.12.0

Fix

  • Fixed version 1.12.0
    pip install --upgrade justhtml==1.12.0

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences