5.1medium
justhtml before 1.14.0 Mutation XSS via custom sanitization policies
- Severity
- 5.1medium CVSS:4.0 by VulnCheck
- Exploit likelihood
- 0.19% (higher than 8% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- VulnCheck
- Also known as
- GHSA-r758-8hxw-4845
Description
justhtml versions 1.13.0 and earlier contain a parser-differential / mutation cross-site scripting (mXSS) vulnerability when using a custom SanitizationPolicy that preserves foreign namespaces (e.g., drop_foreign_namespaces=False with allowlisted SVG/MathML elements or raw-text containers such as <style>). Specially crafted input can sanitize into markup that appears safe but becomes unsafe when re-parsed by a browser or another HTML parser, allowing markup injection. The default safe configuration (sanitize=True) is not affected. Fixed in 1.14.0.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| EmilStenstrom justhtml | before 1.14.0 Not affected: 1.14.0 | CVE List |
| justhtml (PyPI) | from 1.13.0 before 1.14.0 | GitHub Advisory Database |
All scores
| VulnCheck | 5.1medium CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N |
| VulnCheck | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| GitHub | low CVSS:4.0 | 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 |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
justhtml versions 1.13.0 and earlier contain a parser-differential / mutation cross-site scripting (mXSS) vulnerability when using a custom SanitizationPolicy that preserves foreign namespaces (e.g., drop_foreign_namespaces=False with allowlisted SVG/MathML elements or raw-text containers such as <style>). Specially crafted input can sanitize into markup that appears safe but becomes unsafe when re-parsed by a browser or another HTML parser, allowing markup injection. The default safe configuration (sanitize=True) is not affected. Fixed in 1.14.0.
GitHub Advisory Database
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.
NVD (es)
Las versiones 1.13.0 y anteriores de justhtml contienen una vulnerabilidad de cross-site scripting (mXSS) diferencial de analizador / por mutación al usar una SanitizationPolicy personalizada que preserva espacios de nombres externos (por ejemplo, drop_foreign_namespaces=False con elementos SVG/MathML en lista blanca o contenedores de texto sin formato como <style>). Una entrada especialmente diseñada puede sanearse en un marcado que parece seguro pero que se vuelve inseguro cuando es reanalizado por un navegador o por otro analizador HTML, permitiendo la inyección de marcado. La configuración segura predeterminada (sanitize=True) no se ve afectada. Corregido en 1.14.0.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-5751 changed 2026-08-24 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-r758-8hxw-4845 changed 2026-08-24 | CC-BY-4.0 |
| NVD | CVE-2026-5751 changed 2026-10-12 | Public domain |