lxml-html-clean 0.4.7 Patch Fixes XSS Flaw in noscript Comment Handling

A medium-severity cross-site scripting vulnerability in the Python library lxml-html-clean has been patched in version 0.4.7. The flaw allowed attackers to bypass comment removal settings by exploiting differences in how libxml2 and browsers parse noscript elements, enabling script execution without user interaction.
Key points
- CVE-2026-141555 affects lxml-html-clean versions prior to 0.4.7, with a CVSS score of 4.7 (Medium).
- The vulnerability occurs when the Cleaner class is configured with comments=False; it removes conditional comments but retains other comments inside noscript tags.
- Libxml2 parses noscript content as markup, retaining the comment node, while browsers treat the content as raw text, allowing a closing noscript tag inside the comment to terminate the element and execute subsequent attacker-controlled markup.
- The issue was fixed in version 0.4.7, released on November 26, 2026, following a private report by researcher gistrec.
- The default Cleaner configuration removes all comments, making the default setup unaffected; the flaw only manifests when users explicitly disable comment removal.
Background
This incident follows a pattern of security issues in HTML sanitization libraries, including recent flaws in Pydantic AI and browser-use. lxml-html-clean was separated from the main lxml project due to its blocklist-based approach, which the maintainers warn is not suitable for security-sensitive environments, recommending nh3 as an alternative. The current flaw shares a root cause with a prior advisory, GHSA-5jfw-gq64-q45f, also involving noscript parsing discrepancies.
Why it matters
Developers using lxml-html-clean for input sanitization may be exposed to cross-site scripting attacks if they customize the Cleaner to retain comments. While the default configuration is safe, the high attack complexity and required user interaction limit the immediate risk, but the flaw highlights the inherent dangers of blocklist-based HTML cleaning in security contexts.
What to watch
Users should upgrade to lxml-html-clean version 0.4.7 or later to mitigate the vulnerability. Organizations relying on the library for security-sensitive tasks should consider migrating to alternative sanitizers like nh3, as recommended by the project maintainers.
Want the full story? Read the original reporting
Read on CVEs | Zero Wire | Cloudflare Radar