GHSA-r758-8hxw-4845: justhtml: Mutation XSS with custom foreign-namespace sanitization policies
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.
Published Apr 8, 2026 · Updated Apr 9, 2026
Affected packages
justhtml
- Ecosystem
- PyPI
- Affected
- >= 1.13.0, < 1.14.0
- Fixed in
- 1.14.0
- Check
pip show justhtml
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
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.
Credited to EmilStenstrom.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More PyPI vulnerabilities
All PyPI entriesGHSA-jf6w-2mvx-633j
justhtml: to_markdown() code-span blank-line breakout enables XSS
medium6.1Jun 25, 2026GHSA-r8cj-3554-33mr
justhtml introduces denial-of-service hardening
lowMay 8, 2026GHSA-vrx2-77f2-ww34
justhtml has sanitization bypass in custom policies and programmatic DOM
medium6.0Apr 22, 2026GHSA-4p64-v8f5-r2gx
Multiple security fixes in justhtml
low1.3Apr 14, 2026GHSA-c9vm-hv86-f23r
justhtml includes multiple security fixes
mediumApr 10, 2026GHSA-5vp3-3cg6-2rq3
JustHTML is vulnerable to XSS via code fence breakout in <pre> content
high7.1Mar 24, 2026
