GHSA-r758-8hxw-4845: justhtml Cross-Site Scripting Vulnerability

LOW
CWE-79
Published
Advisory Summary

GHSA-r758-8hxw-4845 is a LOW 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 mutation xss with custom foreign-namespace sanitization policies. Remediation is available by upgrading affected packages to version 1.14.0.

GHSA-r758-8hxw-4845 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-r758-8hxw-4845
Severity LOW
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-r758-8hxw-4845

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.14.0
pip install justhtml>=1.14.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-r758-8hxw-4845, 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.14.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 A parser-differential / mutation XSS issue was found in `justhtml` when using a **custom sanitization policy** that preserves foreign namespaces such as SVG or MathML. Under these custom settings, specially crafted input could sanitize into HTML that looked safe at first, but became unsafe when parsed again by a browser or another HTML parser. ## Impact This issue does **not** affect the default safe configuration. You may be affected if you use a custom `SanitizationPolicy` with settings like: - `drop_foreign_namespaces=False` - allowlisted foreign elements such as MathML or SVG - allowlisted raw-text containers such as `<style>` In that case, an attacker could inject markup that survives sanitization and turns into active HTML after re-parsing. ## Affected versions - `justhtml` `<= 1.13.0` ## Fixed version - Fixed in `1.14.0` ## Workarounds Until you upgrade: - keep `drop_foreign_namespaces=True` - avoid allowlisting foreign namespaces for untrusted input - avoid allowlisting raw-text containers such as `<style>` in custom policies ## Notes The default `JustHTML(..., sanitize=True)` behavior was not found to be vulnerable in this issue. ## Credit Discovered by JustHTML author during a LLM-based security review of `justhtml`.

GHSA-r758-8hxw-4845 Affected justhtml Versions

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

References

Frequently Asked Questions

What is GHSA-r758-8hxw-4845?
GHSA-r758-8hxw-4845 is a security vulnerability in justhtml involving Mutation XSS with custom foreign-namespace sanitization policies 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.14.0 across affected packages: justhtml.
What version fixes GHSA-r758-8hxw-4845?
Upgrading to 1.14.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.14.0. Upgrade your dependency to 1.14.0 or later.
What CWE is associated with GHSA-r758-8hxw-4845?
GHSA-r758-8hxw-4845 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-r758-8hxw-4845?
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-r758-8hxw-4845",
  "modified" : "2026-04-08T00:06:17Z",
  "published" : "2026-04-08T00:06:17Z",
  "aliases" : [ ],
  "summary" : "justhtml: Mutation XSS with custom foreign-namespace sanitization policies",
  "details" : "## Summary\n\nA parser-differential / mutation XSS issue was found in `justhtml` when using a **custom sanitization policy** that preserves foreign namespaces such as SVG or MathML.\n\nUnder these custom settings, specially crafted input could sanitize into HTML that looked safe at first, but became unsafe when parsed again by a browser or another HTML parser.\n\n## Impact\n\nThis issue does **not** affect the default safe configuration.\n\nYou may be affected if you use a custom `SanitizationPolicy` with settings like:\n\n- `drop_foreign_namespaces=False`\n- allowlisted foreign elements such as MathML or SVG\n- allowlisted raw-text containers such as `<style>`\n\nIn that case, an attacker could inject markup that survives sanitization and turns into active HTML after re-parsing.\n\n## Affected versions\n\n- `justhtml` `<= 1.13.0`\n\n## Fixed version\n\n- Fixed in `1.14.0`\n\n## Workarounds\n\nUntil you upgrade:\n\n- keep `drop_foreign_namespaces=True`\n- avoid allowlisting foreign namespaces for untrusted input\n- avoid allowlisting raw-text containers such as `<style>` in custom policies\n\n## Notes\n\nThe default `JustHTML(..., sanitize=True)` behavior was not found to be vulnerable in this issue.\n\n## Credit\n\nDiscovered by JustHTML author during a LLM-based security review of `justhtml`.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:A/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "justhtml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.13.0"
      }, {
        "fixed" : "1.14.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/EmilStenstrom/justhtml/security/advisories/GHSA-r758-8hxw-4845"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/EmilStenstrom/justhtml/commit/8adc4dfe31723dc522f44338f9bd98381c92b076"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/EmilStenstrom/justhtml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/EmilStenstrom/justhtml/releases/tag/v1.14.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-08T00:06:17Z",
    "nvd_published_at" : null
  }
}