Executive brief
justhtml is a Python library used to parse and clean HTML content to ensure it is safe for display. Multiple security flaws were found that could allow malicious code to bypass security filters, potentially leading to cross-site scripting (XSS) or the loading of unauthorized external content. These issues primarily affect advanced configurations, such as those handling SVG images or custom security policies.
Technical details
Multiple vulnerabilities exist in justhtml versions 1.15.0 and earlier related to improper neutralization during web page generation. Key issues include: 1) Case-sensitivity gaps where mixed-case tags like <ScRiPt> bypass programmatic DOM sanitization; 2) Policy mutation flaws where modifying global default policies affects the entire process; 3) Foreign-namespace bypasses in SVG/MathML that allow animation elements to mutate attributes post-sanitization; and 4) Serialization injection via crafted doctype names. These flaws allow attackers to bypass intended sanitization filters, particularly when non-default policies or programmatic DOM inputs are used. The issues are resolved in version 1.16.0.
Affected products
- EmilStenstrom justhtml <= 1.15.0
Timeline
- 2026-04-12: patched: Version 1.16.0 released.
- 2026-04-14: advisory: GitHub Advisory GHSA-4p64-v8f5-r2gx published.