GHSA-qvc2-mg72-jjhx: Justhtml Cross-Site Scripting Vulnerability

MODERATE
CWE-79
Published
Advisory Summary

GHSA-qvc2-mg72-jjhx is a MODERATE cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Justhtml libraries in the PyPI ecosystem. The issue involves justhtml affected by mutation xss via literal text serialization in raw text elements (style/script). Remediation is available by upgrading affected packages to version 1.12.0.

GHSA-qvc2-mg72-jjhx at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-qvc2-mg72-jjhx
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Justhtml
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix GHSA-qvc2-mg72-jjhx

To remediate this vulnerability, upgrade all affected Justhtml dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

justhtml fixed: 1.12.0
pip install justhtml>=1.12.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show justhtml

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-qvc2-mg72-jjhx, inspect your installed packages using pip:

pip show justhtml

Analyze the terminal output to locate any version of Justhtml in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.12.0), your application is affected.

Note: The pip show justhtml command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Justhtml, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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)

GHSA-qvc2-mg72-jjhx Affected Justhtml Versions

1 component(s)
Fixed Versions:
1.12.0
Product / Package Ecosystem Affected Versions Fixed Version
justhtml
PyPI
< 1.12.0
1.12.0

References

Frequently Asked Questions

What is GHSA-qvc2-mg72-jjhx?
GHSA-qvc2-mg72-jjhx is a security vulnerability in Justhtml involving JustHTML Affected by Mutation XSS via Literal Text Serialization in Raw Text Elements (style/script) under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Justhtml versions are affected?
Affected versions include releases prior to 1.12.0 across affected packages: justhtml.
What version fixes GHSA-qvc2-mg72-jjhx?
Upgrading to 1.12.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is justhtml affected?
Yes, justhtml is affected in releases prior to 1.12.0. Upgrade your dependency to 1.12.0 or later.
What CWE is associated with GHSA-qvc2-mg72-jjhx?
GHSA-qvc2-mg72-jjhx is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check PyPI dependencies for GHSA-qvc2-mg72-jjhx?
Run the dependency tree command: 'pip show justhtml'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-qvc2-mg72-jjhx",
  "modified" : "2026-03-18T20:19:47Z",
  "published" : "2026-03-18T20:19:47Z",
  "aliases" : [ ],
  "summary" : "JustHTML Affected by Mutation XSS via Literal Text Serialization in Raw Text Elements (style/script)",
  "details" : "## Summary\n\nSanitized DOM trees can be unsafe to serialize when a custom policy allows raw-text elements such as `<style>` or `<script>`.\n\nThe 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.\n\nThe default sanitization policy is not affected because it drops the contents of `style` and `script`.\n\n## Details\n\nThe root cause is in HTML serialization of raw-text elements. In serialize.py, text children of `script` and `style` are emitted verbatim:\n\n```python\n_LITERAL_TEXT_SERIALIZATION_ELEMENTS = frozenset({\"script\", \"style\"})\n\ndef _serialize_text_for_parent(text: str | None, parent_name: str | None) -> str:\n    if not text:\n        return \"\"\n    if parent_name in _LITERAL_TEXT_SERIALIZATION_ELEMENTS:\n        return text\n    return _escape_text(text)",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "justhtml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.12.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.11.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/EmilStenstrom/justhtml/security/advisories/GHSA-qvc2-mg72-jjhx"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/EmilStenstrom/justhtml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-18T20:19:47Z",
    "nvd_published_at" : null
  }
}