Every CVESearch/Get API key

CVE-2026-141555

lxml-html-clean: Cleaner(comments=False) keeps a comment that closes <noscript> in the browser, which allows XSS (PyPI)

Explain with AI
ChatGPTClaudeGoogle AI
Severity
4.7Medium
Network attack, no privileges, needs user interactionCVSS 3.1, CVE List
Exploitation
Proof of concept
CISA reports one, no source links it
Exploit chance
0.48% in 30 days
Percentile43rd
EPSS, scored
Listed fix
0.4.7 for lxml-html-clean
From GitHub Advisories and OSV

Overview

lxml-html-clean is an HTML cleaning library for Python. Prior to 0.4.7, Cleaner in lxml_html_clean/clean.py configured with comments=False uses kill_conditional_comments 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.

CVSS 3.1 vector

Exploitability

Attack vector
Network
Complexity
High
Privileges needed
None
User interaction
Required

Impact

Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N

Exploit chance over time

Unchanged since Dec 3, 2026
EPSS score 0.48% every day from Dec 3, 2026 to Dec 4, 2026.

Affected

Packages 1

Affected packages
PackageAffectedFixed
lxml-html-clean
PyPI
through 0.4.6
0.4.7
before 0.4.7, plus listed versions
0.1.00.1.10.2.00.2.10.2.2
Show 9 more versionsShow less
0.3.00.3.10.4.00.4.10.4.20.4.30.4.40.4.50.4.6
0.4.7

Products 1

Sources

CVE List Score usedCVSS 3.14.7

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 lxml_html_clean/clean.py configured with comments=False uses kill_conditional_comments 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.

Record
CVE-2026-141555
CVSS 3.1
4.7 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
Weakness
CWE-79
Updated
2026-12-02
EUVDEUVD-2026-141830CVSS 3.14.7

lxml_html_clean: Cleaner(comments=False) keeps a comment that closes <noscript> in the browser, which allows XSS

Record
EUVD-2026-141830
CVSS 3.1
4.7 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
Updated
2026-12-03
GitHub AdvisoriesGHSA-vfhw-gfwp-vxfjCVSS 3.14.7

lxml_html_clean: Cleaner(comments=False) keeps a comment that closes <noscript> in the browser, which allows XSS

Summary

With comments=False, the Cleaner removes only IE conditional comments (lxml_html_clean/clean.py:363-366, kill_conditional_comments at 599-607) and keeps every other comment (421-422, 511-513). libxml2 parses the content of <noscript> as markup, so <!--</noscript><img src=x onerror=...>--> is a single comment node and is returned unchanged. A browser with scripting enabled treats <noscript> as raw text, closes it at the first </noscript>, and parses the rest as live markup. The <img onerror> handler runs when the cleaned output is rendered in a page, with no click.

The default Cleaner() is not affected, because it removes all comments. The same comment outside <noscript> stays an inert comment in the browser.

This is the parser difference from GHSA-5jfw-gq64-q45f. The </noscript check added for it (clean.py:668-670) is applied to <style> text only.

Tested on lxml_html_clean 0.4.6 from PyPI (same commit as main), lxml 6.1.3, libxml2 2.14.6, Python 3.12.16, Chromium 159.0.8154.13 headless, with no network. The output is byte-identical on 0.1.0, 0.2.0, 0.4.0, 0.4.4 (lxml 5.1.0, libxml2 2.12.3) and 0.4.5.

Reproduction

from lxml_html_clean import Cleaner
P = '''<noscript><!--</noscript><img src=x onerror="window.__fired=(window.__fired||0)+1;document.title='FIRED'">--></noscript>'''
print(Cleaner(comments=False).clean_html(P))
print(Cleaner().clean_html(P))
[A1] claim: comment in noscript, comments=False
  out: <noscript><!--</noscript><img src=x onerror="window.__fired=(window.__fired||0)+1;document.title='FIRED'">--></noscript>
[A2] same input, default Cleaner()
  out: <noscript></noscript>
[A3] same comment outside noscript, comments=False
  out: <div><!--</noscript><img src=x onerror="window.__fired=(window.__fired||0)+1;document.title='FIRED'">--></div>

Each output was placed inside a <div> of a static page and loaded in Chromium:

A1.html                    title=FIRED  fired=1 scripting_on=True imgs=['<img src="x" onerror="window.__fired=(window.__fired||0)+1;document.title=\'FIRED\'">'] noscript=[{'children': 0, 'text': '<!--'}] comments=[]
A2.html                    title=CLEAN  fired=0 scripting_on=True imgs=[] noscript=[{'children': 0, 'text': ''}] comments=[]
A3.html                    title=CLEAN  fired=0 scripting_on=True imgs=[] noscript=[] comments=['</noscript><img src=x onerror="window.__']

Assigning the cleaned string to innerHTML also runs the handler.

Suggested fix

In kill_conditional_comments, also drop a comment when its text contains </ followed by the tag name of one of its ancestors. With that change the payload becomes <noscript></noscript>, and comments such as <!-- note: 1 < 2 --> and <!-- <b>old</b> --> are kept. Reusing _looks_like_tag_content (clean.py:52-54) on the comment text also stops the payload, but it removes commented-out markup like <!-- <b>old</b> --> too.

Record
GHSA-vfhw-gfwp-vxfj
CVSS 3.1
4.7 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
Weakness
CWE-79
Updated
2026-12-03
NVDCVSS 3.14.7

lxml-html-clean is an HTML cleaning library for Python. Prior to 0.4.7, Cleaner in lxml_html_clean/clean.py configured with comments=False uses kill_conditional_comments 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.

Record
CVE-2026-141555
CVSS 3.1
4.7 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
Weakness
CWE-79
Updated
2026-12-03
OSVCVSS 3.14.7

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 lxml_html_clean/clean.py configured with comments=False uses kill_conditional_comments 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.

Record
CVE-2026-141555
CVSS 3.1
4.7 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
Weakness
CWE-79
Updated
2026-12-03
OSVGHSA-vfhw-gfwp-vxfjCVSS 3.14.7

lxml_html_clean: Cleaner(comments=False) keeps a comment that closes <noscript> in the browser, which allows XSS

Summary

With comments=False, the Cleaner removes only IE conditional comments (lxml_html_clean/clean.py:363-366, kill_conditional_comments at 599-607) and keeps every other comment (421-422, 511-513). libxml2 parses the content of <noscript> as markup, so <!--</noscript><img src=x onerror=...>--> is a single comment node and is returned unchanged. A browser with scripting enabled treats <noscript> as raw text, closes it at the first </noscript>, and parses the rest as live markup. The <img onerror> handler runs when the cleaned output is rendered in a page, with no click.

The default Cleaner() is not affected, because it removes all comments. The same comment outside <noscript> stays an inert comment in the browser.

This is the parser difference from GHSA-5jfw-gq64-q45f. The </noscript check added for it (clean.py:668-670) is applied to <style> text only.

Tested on lxml_html_clean 0.4.6 from PyPI (same commit as main), lxml 6.1.3, libxml2 2.14.6, Python 3.12.16, Chromium 159.0.8154.13 headless, with no network. The output is byte-identical on 0.1.0, 0.2.0, 0.4.0, 0.4.4 (lxml 5.1.0, libxml2 2.12.3) and 0.4.5.

Reproduction

from lxml_html_clean import Cleaner
P = '''<noscript><!--</noscript><img src=x onerror="window.__fired=(window.__fired||0)+1;document.title='FIRED'">--></noscript>'''
print(Cleaner(comments=False).clean_html(P))
print(Cleaner().clean_html(P))
[A1] claim: comment in noscript, comments=False
  out: <noscript><!--</noscript><img src=x onerror="window.__fired=(window.__fired||0)+1;document.title='FIRED'">--></noscript>
[A2] same input, default Cleaner()
  out: <noscript></noscript>
[A3] same comment outside noscript, comments=False
  out: <div><!--</noscript><img src=x onerror="window.__fired=(window.__fired||0)+1;document.title='FIRED'">--></div>

Each output was placed inside a <div> of a static page and loaded in Chromium:

A1.html                    title=FIRED  fired=1 scripting_on=True imgs=['<img src="x" onerror="window.__fired=(window.__fired||0)+1;document.title=\'FIRED\'">'] noscript=[{'children': 0, 'text': '<!--'}] comments=[]
A2.html                    title=CLEAN  fired=0 scripting_on=True imgs=[] noscript=[{'children': 0, 'text': ''}] comments=[]
A3.html                    title=CLEAN  fired=0 scripting_on=True imgs=[] noscript=[] comments=['</noscript><img src=x onerror="window.__']

Assigning the cleaned string to innerHTML also runs the handler.

Suggested fix

In kill_conditional_comments, also drop a comment when its text contains </ followed by the tag name of one of its ancestors. With that change the payload becomes <noscript></noscript>, and comments such as <!-- note: 1 < 2 --> and <!-- <b>old</b> --> are kept. Reusing _looks_like_tag_content (clean.py:52-54) on the comment text also stops the payload, but it removes commented-out markup like <!-- <b>old</b> --> too.

Record
GHSA-vfhw-gfwp-vxfj
CVSS 3.1
4.7 MediumCVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
Weakness
CWE-79
Updated
2026-12-03

History

Recorded by Every CVE

Changes recorded by Every CVE
DayChangedSources
Published dateEUVD
Affected packages, referencesOSV
Affected packages, key facts, referencesGitHub Advisories, NVD
Key facts, referencesCVE List
Other IDs, referencesOSV
Other IDs, published dateEUVD, NVD
First indexedCVE List

Upstream dates may differ.

References

MoveEnter Open