CVE-2026-141555: lxml-html-clean: Cleaner(comments=False) keeps a comment that closes <noscript> in the browser, which allows XSS
lxml-html-clean is an HTML cleaning library for Python. Prior to 0.4.7, Cleaner in lxmlhtmlclean/clean.py configured with comments=False uses killconditionalcomments to remove conditional comments but retains other comments inside noscript. libxml2 parses the noscript content as markup and retains the comment as a node, while a browser with scripting enabled treats the content as raw text. A closing noscript tag inside a retained comment can terminate the element in the browser, causing following attacker-controlled markup to execute when cleaned HTML is rendered, without a click. The default Cleaner removes all comments, and the same comment outside noscript remains inert. An earlier check for a noscript closing tag applies to style text rather than retained comments. This issue is fixed in 0.4.7.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
lxml-html-cleanto a version that resolves this vulnerability.Fixed in 0.4.7
Event History
Frequently Asked Questions
Which deployments are exposed to this issue?
Deployments using lxml-html-clean before 0.4.7 are exposed only when they configure Cleaner with comments=False and render the cleaned output in a browser with scripting enabled. The default Cleaner configuration removes all comments and is not affected by this specific issue.
What must an attacker supply for exploitation?
An attacker must be able to place crafted HTML into content processed by the cleaner. The payload relies on a retained comment inside a noscript element containing a closing noscript tag, followed by attacker-controlled markup that the browser interprets after the element is terminated.
Does exploitation require user interaction?
No. The affected cleaned HTML can execute attacker-controlled markup when rendered in a browser, without a click.
What can be done before upgrading?
Avoid using Cleaner with comments=False for untrusted HTML. Configure the cleaner to remove all comments, particularly when sanitized output may be rendered in browsers.
How can I determine whether my application is affected?
Check whether it uses lxml-html-clean earlier than 0.4.7 and creates a Cleaner with comments=False. Also verify whether untrusted cleaned HTML can contain noscript elements and is later rendered in a scripting-enabled browser.