GHSA-4p64-v8f5-r2gx: Multiple security fixes in justhtml
Summary justhtml 1.16.0 fixes multiple security issues in sanitization, serialization, and programmatic DOM handling. Most of these issues affected one of these advanced paths rather than ordinary parsed HTML with the default safe settings: - programmatic DOM input to sanitize() or sanitizedom() - reused or mutated sanitization policy objects - custom policies that preserve foreign namespaces such as SVG or MathML…
Published Apr 14, 2026
Affected packages
justhtml
- Ecosystem
- PyPI
- Affected
- <= 1.15.0
- Fixed in
- 1.16.0
- Check
pip show justhtml
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
justhtml 1.16.0 fixes multiple security issues in sanitization, serialization, and programmatic DOM handling.
Most of these issues affected one of these advanced paths rather than ordinary parsed HTML with the default safe settings:
- programmatic DOM input to
sanitize()orsanitize_dom() - reused or mutated sanitization policy objects
- custom policies that preserve foreign namespaces such as SVG or MathML
Affected versions
justhtml<= 1.15.0
Fixed version
justhtml1.16.0released on April 12, 2026
Impact
Policy reuse and mutation
Nested mutation of sanitization policy internals could weaken later sanitization by leaving stale compiled sanitizers active, or by mutating exported default policy internals process-wide.
In-memory sanitization gaps
Programmatic DOM sanitization could miss dangerous mixed-case tag names such as ScRiPt or StYlE, and custom drop_content_tags values such as {"SCRIPT"} could silently fail to drop dangerous subtrees.
Serialization injection
Crafted programmatic doctype names could serialize into active markup before the document body.
Foreign-namespace policy bypasses
Custom policies that preserve SVG or MathML could allow active SVG features to survive sanitization, including:
- animation elements such as
<set>and<animate>that mutate already-sanitized attributes after sanitization - presentation attributes such as
fill,clip-path,mask,marker-start, andcursorcontaining externalurl(...)references - programmatic DOM trees that claim
namespace="html"but serialize as<svg>or<math>, bypassing foreign-content checks
Rawtext hardening gap
Mixed-case programmatic style or script nodes could bypass rawtext hardening and preserve active stylesheet content such as remote @import rules.
Default configuration
Most of these issues did not affect the normal JustHTML(..., sanitize=True) path for ordinary parsed HTML.
The main exceptions were policy-mutation issues, which could weaken later sanitization if code mutated nested state on reused policy objects or exported defaults.
Recommended action
Upgrade to justhtml 1.16.0.
If you cannot upgrade immediately:
- do not mutate
DEFAULT_POLICY,DEFAULT_DOCUMENT_POLICY, or nested policy internals - avoid reusing policy objects after mutating nested state
- avoid preserving SVG or MathML for untrusted input
- avoid preserving
styleorscriptin custom policies for untrusted input - avoid serializing untrusted programmatic doctypes or DOM trees
Credit
Discovered during an internal 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-c9vm-hv86-f23r
justhtml includes multiple security fixes
mediumApr 10, 2026GHSA-r758-8hxw-4845
justhtml: Mutation XSS with custom foreign-namespace sanitization policies
low2.1Apr 8, 2026GHSA-5vp3-3cg6-2rq3
JustHTML is vulnerable to XSS via code fence breakout in <pre> content
high7.1Mar 24, 2026
