{"id":"CVE-2026-141556","aliases":["EUVD-2026-141834","GHSA-5gvf-7wqf-r4cv"],"status":"published","title":"lxml-html-clean: Cleaner(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values","description":"lxml-html-clean is an HTML cleaning library for Python. In versions through 0.4.6, Cleaner in lxml_html_clean/clean.py configured with safe_attrs_only=False removes JavaScript links using rewrite_links, which visits only attributes in lxml.html.defs.link_attrs and misses iframe srcdoc and SVG animation attributes. When an iframe is retained through host_whitelist, srcdoc takes priority over its source and can cause attacker-controlled HTML to run without a click. With remove_unknown_tags=False, SVG set or animate elements can use attributeName and attributes such as to, from, by, or values to change a link destination to a JavaScript URL that runs when clicked. This vulnerability 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.00389,"percentile":0.35157,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true,"poc_reported":true},"cwes":["CWE-184","CWE-79"],"published":"2026-12-02T20:15:03Z","modified":"2026-12-05T05:19:31Z","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-5gvf-7wqf-r4cv","tags":["x_refsource_CONFIRM","exploit","advisory","web"]},{"url":"https://github.com/fedora-python/lxml_html_clean/commit/883db209e04222a1959f7773f5bde1da0224fbe1","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-141556","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-5gvf-7wqf-r4cv"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/141xxx/CVE-2026-141556.json","tags":["advisory"]},{"url":"https://github.com/fedora-python/lxml_html_clean","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2026-141556","title":"lxml-html-clean: Cleaner(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values","description":"lxml-html-clean is an HTML cleaning library for Python. In versions through 0.4.6, Cleaner in lxml_html_clean/clean.py configured with safe_attrs_only=False removes JavaScript links using rewrite_links, which visits only attributes in lxml.html.defs.link_attrs and misses iframe srcdoc and SVG animation attributes. When an iframe is retained through host_whitelist, srcdoc takes priority over its source and can cause attacker-controlled HTML to run without a click. With remove_unknown_tags=False, SVG set or animate elements can use attributeName and attributes such as to, from, by, or values to change a link destination to a JavaScript URL that runs when clicked. This vulnerability is fixed in 0.4.7.","status":"published","published":"2026-12-02T20:15:03.484Z","modified":"2026-12-05T03:34:58.073Z","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","CWE-184"],"ssvc":{"exploitation":"poc","automatable":"no","technical_impact":"partial","date":"2026-12-05"},"updated_at":"2026-12-05T03:39:30.760404Z"}],"euvd":[{"id":"EUVD-2026-141834","description":"lxml-html-clean is an HTML cleaning library for Python. In versions through 0.4.6, Cleaner in lxml_html_clean/clean.py configured with safe_attrs_only=False removes JavaScript links using rewrite_links, which visits only attributes in lxml.html.defs.link_attrs and misses iframe srcdoc and SVG animation attributes. When an iframe is retained through host_whitelist, srcdoc takes priority over its source and can cause attacker-controlled HTML to run without a click. With remove_unknown_tags=False, SVG set or animate elements can use attributeName and attributes such as to, from, by, or values to change a link destination to a JavaScript URL that runs when clicked. This vulnerability is fixed in 0.4.7.","status":"published","published":"2026-12-02T20:15:03Z","modified":"2026-12-05T03:34:58Z","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-05T05:44:55.871443Z"}],"ghsa":[{"id":"GHSA-5gvf-7wqf-r4cv","title":"lxml_html_clean: Cleaner(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values","description":"## Summary\n\nWhen `safe_attrs_only=False`, the Cleaner still tries to remove JavaScript (`javascript=True` is the default): it deletes `on*` attributes (`lxml_html_clean/clean.py:381-389` in 0.4.6) and blanks `javascript:` URLs through `doc.rewrite_links(self._remove_javascript_link)` (`clean.py:390`). `rewrite_links` only visits the attributes listed in `lxml.html.defs.link_attrs`, and two kinds of attributes that can carry script are not on that list:\n\n1. `srcdoc` on `\u003ciframe\u003e`. Its value is a complete HTML document that the browser renders inside the frame. With `host_whitelist` set, the `\u003ciframe\u003e` itself is kept, and `srcdoc` takes priority over `src`, so the whitelisted `src` no longer matters.\n2. `to`, `values` (and `from`, `by`) on the SVG animation elements `\u003cset\u003e` and `\u003canimate\u003e`. With `attributeName=\"href\"` they set the `href` of the enclosing SVG `\u003ca\u003e` at runtime, so `javascript:` ends up on the link even though the Cleaner removed it from `href` itself. This one also needs `remove_unknown_tags=False`, otherwise `\u003cset\u003e`/`\u003canimate\u003e` are dropped.\n\nThis is the same root cause as GHSA-4jhm-jv67-739f (`xlink:href` with `safe_attrs_only=False`): an attribute missing from `link_attrs` (CWE-184). In both configurations below the same Cleaner turns `href=\"javascript:...\"` into `href=\"\"` and deletes `onclick`, so script removal is clearly still meant to apply.\n\nThe default `Cleaner()` is not affected: `safe_attrs_only=True` removes `srcdoc`, `to` and `values`.\n\n## Affected versions\n\nCleaner output was checked on lxml_html_clean 0.1.0, 0.4.0 and 0.4.6 from PyPI, and on the `noscript_comment` fix branch (0.4.7, commit 0546dc2), with lxml 6.1.3, libxml2 2.14.6 and Python 3.12. The output is the same in all of them. The browser test below was run on 0.4.6.\n\n## Reproduction\n\n```python\nfrom lxml_html_clean import Cleaner\n\nc_ifr = Cleaner(host_whitelist=['www.youtube.com'], safe_attrs_only=False)\nc_svg = Cleaner(safe_attrs_only=False, remove_unknown_tags=False)\n\nprint(c_ifr.clean_html('\u003ciframe src=\"https://www.youtube.com/embed/x\" srcdoc=\"\u0026lt;b\u0026gt;MARK\u0026lt;/b\u0026gt;\"\u003e\u003c/iframe\u003e'))\nprint(c_svg.clean_html('\u003csvg\u003e\u003ca\u003e\u003cset attributename=\"href\" to=\"javascript:MARK\"\u003e\u003c/set\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e'))\nprint(c_svg.clean_html('\u003csvg\u003e\u003ca\u003e\u003canimate attributename=\"href\" values=\"javascript:MARK\"\u003e\u003c/animate\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e'))\n# controls, same configurations\nprint(c_svg.clean_html('\u003csvg\u003e\u003ca href=\"javascript:MARK\"\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e'))\nprint(c_svg.clean_html('\u003csvg\u003e\u003ca onclick=\"MARK\"\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e'))\nprint(Cleaner(host_whitelist=['www.youtube.com']).clean_html('\u003ciframe src=\"https://www.youtube.com/embed/x\" srcdoc=\"\u0026lt;b\u0026gt;MARK\u0026lt;/b\u0026gt;\"\u003e\u003c/iframe\u003e'))\n```\n\n```text\n\u003ciframe src=\"https://www.youtube.com/embed/x\" srcdoc=\"\u0026lt;b\u0026gt;MARK\u0026lt;/b\u0026gt;\"\u003e\u003c/iframe\u003e\n\u003csvg\u003e\u003ca\u003e\u003cset attributename=\"href\" to=\"javascript:MARK\"\u003e\u003c/set\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e\n\u003csvg\u003e\u003ca\u003e\u003canimate attributename=\"href\" values=\"javascript:MARK\"\u003e\u003c/animate\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e\n\u003csvg\u003e\u003ca href=\"\"\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e\n\u003csvg\u003e\u003ca\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e\n\u003ciframe src=\"https://www.youtube.com/embed/x\"\u003e\u003c/iframe\u003e\n```\n\nBrowser check (headless Chromium, no network, 0.4.6): each cleaned output was placed in a static page. The script in `srcdoc` ran when the page loaded, with no interaction. For `\u003cset\u003e` and `\u003canimate\u003e`, the `javascript:` URL ran when the SVG link was clicked. The click was simulated with `dispatchEvent(new MouseEvent(\"click\"))`, not a real pointer click. The controls (`href=\"javascript:...\"` and the iframe without `srcdoc`) did not run anything.\n\n## Impact\n\nStored or reflected XSS in applications that clean user HTML with `safe_attrs_only=False` and render the result. The `srcdoc` variant runs without a click when `host_whitelist` is also set, for example to allow video embeds. The SVG variant needs `remove_unknown_tags=False` as well, plus one click on the link.\n\n## Suggested fix\n\nIn the `if self.javascript:` block of `Cleaner.__call__`:\n\n- delete `srcdoc` from every element;\n- on `\u003cset\u003e` and `\u003canimate\u003e`, when `attributeName` is `href` or `xlink:href`, delete `to`, `from`, `by` and `values`. Dropping them is simpler than scheme-checking them, because `values` is a `;`-separated list and a check on the whole string does not see every item.","status":"published","published":"2026-12-03T02:41:48Z","modified":"2026-12-03T02:41:51Z","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","CWE-184"],"updated_at":"2026-12-03T03:11:39.517135Z"}],"nvd":[{"id":"CVE-2026-141556","description":"lxml-html-clean is an HTML cleaning library for Python. In versions through 0.4.6, Cleaner in lxml_html_clean/clean.py configured with safe_attrs_only=False removes JavaScript links using rewrite_links, which visits only attributes in lxml.html.defs.link_attrs and misses iframe srcdoc and SVG animation attributes. When an iframe is retained through host_whitelist, srcdoc takes priority over its source and can cause attacker-controlled HTML to run without a click. With remove_unknown_tags=False, SVG set or animate elements can use attributeName and attributes such as to, from, by, or values to change a link destination to a JavaScript URL that runs when clicked. This vulnerability is fixed in 0.4.7.","status":"published","published":"2026-12-02T21:18:11.31Z","modified":"2026-12-05T05:19:31.143Z","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","CWE-184"],"ssvc":{"exploitation":"poc","automatable":"no","technical_impact":"partial","date":"2026-12-05"},"updated_at":"2026-12-05T05:22:46.281266Z"}],"osv":[{"id":"CVE-2026-141556","title":"lxml-html-clean: Cleaner(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values","description":"lxml-html-clean is an HTML cleaning library for Python. In versions through 0.4.6, Cleaner in lxml_html_clean/clean.py configured with safe_attrs_only=False removes JavaScript links using rewrite_links, which visits only attributes in lxml.html.defs.link_attrs and misses iframe srcdoc and SVG animation attributes. When an iframe is retained through host_whitelist, srcdoc takes priority over its source and can cause attacker-controlled HTML to run without a click. With remove_unknown_tags=False, SVG set or animate elements can use attributeName and attributes such as to, from, by, or values to change a link destination to a JavaScript URL that runs when clicked. This vulnerability is fixed in 0.4.7.","status":"published","published":"2026-12-02T20:15:03.484Z","modified":"2026-12-05T04:46:14.224342555Z","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-184","CWE-79"],"updated_at":"2026-12-03T21:10:05.302032Z"},{"id":"GHSA-5gvf-7wqf-r4cv","title":"lxml_html_clean: Cleaner(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values","description":"## Summary\n\nWhen `safe_attrs_only=False`, the Cleaner still tries to remove JavaScript (`javascript=True` is the default): it deletes `on*` attributes (`lxml_html_clean/clean.py:381-389` in 0.4.6) and blanks `javascript:` URLs through `doc.rewrite_links(self._remove_javascript_link)` (`clean.py:390`). `rewrite_links` only visits the attributes listed in `lxml.html.defs.link_attrs`, and two kinds of attributes that can carry script are not on that list:\n\n1. `srcdoc` on `\u003ciframe\u003e`. Its value is a complete HTML document that the browser renders inside the frame. With `host_whitelist` set, the `\u003ciframe\u003e` itself is kept, and `srcdoc` takes priority over `src`, so the whitelisted `src` no longer matters.\n2. `to`, `values` (and `from`, `by`) on the SVG animation elements `\u003cset\u003e` and `\u003canimate\u003e`. With `attributeName=\"href\"` they set the `href` of the enclosing SVG `\u003ca\u003e` at runtime, so `javascript:` ends up on the link even though the Cleaner removed it from `href` itself. This one also needs `remove_unknown_tags=False`, otherwise `\u003cset\u003e`/`\u003canimate\u003e` are dropped.\n\nThis is the same root cause as GHSA-4jhm-jv67-739f (`xlink:href` with `safe_attrs_only=False`): an attribute missing from `link_attrs` (CWE-184). In both configurations below the same Cleaner turns `href=\"javascript:...\"` into `href=\"\"` and deletes `onclick`, so script removal is clearly still meant to apply.\n\nThe default `Cleaner()` is not affected: `safe_attrs_only=True` removes `srcdoc`, `to` and `values`.\n\n## Affected versions\n\nCleaner output was checked on lxml_html_clean 0.1.0, 0.4.0 and 0.4.6 from PyPI, and on the `noscript_comment` fix branch (0.4.7, commit 0546dc2), with lxml 6.1.3, libxml2 2.14.6 and Python 3.12. The output is the same in all of them. The browser test below was run on 0.4.6.\n\n## Reproduction\n\n```python\nfrom lxml_html_clean import Cleaner\n\nc_ifr = Cleaner(host_whitelist=['www.youtube.com'], safe_attrs_only=False)\nc_svg = Cleaner(safe_attrs_only=False, remove_unknown_tags=False)\n\nprint(c_ifr.clean_html('\u003ciframe src=\"https://www.youtube.com/embed/x\" srcdoc=\"\u0026lt;b\u0026gt;MARK\u0026lt;/b\u0026gt;\"\u003e\u003c/iframe\u003e'))\nprint(c_svg.clean_html('\u003csvg\u003e\u003ca\u003e\u003cset attributename=\"href\" to=\"javascript:MARK\"\u003e\u003c/set\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e'))\nprint(c_svg.clean_html('\u003csvg\u003e\u003ca\u003e\u003canimate attributename=\"href\" values=\"javascript:MARK\"\u003e\u003c/animate\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e'))\n# controls, same configurations\nprint(c_svg.clean_html('\u003csvg\u003e\u003ca href=\"javascript:MARK\"\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e'))\nprint(c_svg.clean_html('\u003csvg\u003e\u003ca onclick=\"MARK\"\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e'))\nprint(Cleaner(host_whitelist=['www.youtube.com']).clean_html('\u003ciframe src=\"https://www.youtube.com/embed/x\" srcdoc=\"\u0026lt;b\u0026gt;MARK\u0026lt;/b\u0026gt;\"\u003e\u003c/iframe\u003e'))\n```\n\n```text\n\u003ciframe src=\"https://www.youtube.com/embed/x\" srcdoc=\"\u0026lt;b\u0026gt;MARK\u0026lt;/b\u0026gt;\"\u003e\u003c/iframe\u003e\n\u003csvg\u003e\u003ca\u003e\u003cset attributename=\"href\" to=\"javascript:MARK\"\u003e\u003c/set\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e\n\u003csvg\u003e\u003ca\u003e\u003canimate attributename=\"href\" values=\"javascript:MARK\"\u003e\u003c/animate\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e\n\u003csvg\u003e\u003ca href=\"\"\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e\n\u003csvg\u003e\u003ca\u003e\u003ctext\u003ex\u003c/text\u003e\u003c/a\u003e\u003c/svg\u003e\n\u003ciframe src=\"https://www.youtube.com/embed/x\"\u003e\u003c/iframe\u003e\n```\n\nBrowser check (headless Chromium, no network, 0.4.6): each cleaned output was placed in a static page. The script in `srcdoc` ran when the page loaded, with no interaction. For `\u003cset\u003e` and `\u003canimate\u003e`, the `javascript:` URL ran when the SVG link was clicked. The click was simulated with `dispatchEvent(new MouseEvent(\"click\"))`, not a real pointer click. The controls (`href=\"javascript:...\"` and the iframe without `srcdoc`) did not run anything.\n\n## Impact\n\nStored or reflected XSS in applications that clean user HTML with `safe_attrs_only=False` and render the result. The `srcdoc` variant runs without a click when `host_whitelist` is also set, for example to allow video embeds. The SVG variant needs `remove_unknown_tags=False` as well, plus one click on the link.\n\n## Suggested fix\n\nIn the `if self.javascript:` block of `Cleaner.__call__`:\n\n- delete `srcdoc` from every element;\n- on `\u003cset\u003e` and `\u003canimate\u003e`, when `attributeName` is `href` or `xlink:href`, delete `to`, `from`, `by` and `values`. Dropping them is simpler than scheme-checking them, because `values` is a `;`-separated list and a check on the whole string does not see every item.","status":"published","published":"2026-12-03T02:41:48Z","modified":"2026-12-03T03:00:04.135069332Z","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-184","CWE-79"],"updated_at":"2026-12-03T03:09:16.659991Z"}]}}
