GitHub Advisoryadvisory · PyPI
GHSA-4p64-v8f5-r2gx Multiple security fixes in justhtml
LOW
Official page ↗
- Ecosystem
- PyPI
- Packages
- justhtml
- Severity
- Low
- CVSS vector
- 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/E:U
- Weaknesses
- CWE-178, CWE-436, CWE-471, CWE-79
- Reviewed
- 2026-04-14
Affected packages
• PyPI justhtml: < 1.16.0 → fixed in 1.16.0
Description
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 `sanitize_dom()`
• reused or mutated sanitization policy objects
• custom policies that preserve foreign namespaces such as SVG or MathML
Affected versions
• `justhtml` `` and `` that mutate already-sanitized attributes after sanitization
• presentation attributes such as `fill`, `clip-path`, `mask`, `marker-start`, and `cursor` containing external `url(...)` references
• programmatic DOM trees that claim `namespace="html"` but serialize as `` or ``, 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 `style` or `script` in custom policies for untrusted input
• avoid serializing untrusted programmatic doctypes or DOM trees
Credit
Discovered during an internal security review of `justhtml`.