CVE-2026-141556: lxml_html_clean Cleaner(safe_attrs_only=False) Keeps Javascript: Vulnerability
MODERATECVE-2026-141556 is a MODERATE (CVSS 4.7) cleaner(safe_attrs_only=false) keeps javascript: vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting lxml_html_clean libraries in the PyPI ecosystem. The issue involves cleaner(safe_attrs_only=false) keeps javascript: in iframe srcdoc and svg animation values. Remediation is available by upgrading affected packages to version 0.4.7.
CVE-2026-141556 at a Glance
Security Impact
CVSS: 4.7
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N).
How to Fix CVE-2026-141556
To remediate this vulnerability, upgrade all affected lxml_html_clean dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install lxml-html-clean>=0.4.7
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show lxml-html-clean
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-141556, inspect your installed packages using pip:
pip show lxml-html-clean
Analyze the terminal output to locate any version of lxml_html_clean in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.4.7), your application is affected.
Note: The pip show lxml-html-clean command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In lxml_html_clean, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-141556 Affected lxml_html_clean Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
lxml-html-clean
|
PyPI |
< 0.4.7
|
0.4.7
|
References
Frequently Asked Questions
What is CVE-2026-141556?
Which lxml_html_clean versions are affected?
What version fixes CVE-2026-141556?
Is lxml-html-clean affected?
What is the CVSS score of CVE-2026-141556?
What CWE is associated with CVE-2026-141556?
How can I check PyPI dependencies for CVE-2026-141556?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-5gvf-7wqf-r4cv",
"modified" : "2026-12-03T02:41:48Z",
"published" : "2026-12-03T02:41:48Z",
"aliases" : [ "CVE-2026-141556" ],
"summary" : "lxml_html_clean: Cleaner(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values",
"details" : "## 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 `<iframe>`. Its value is a complete HTML document that the browser renders inside the frame. With `host_whitelist` set, the `<iframe>` 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 `<set>` and `<animate>`. With `attributeName=\"href\"` they set the `href` of the enclosing SVG `<a>` 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 `<set>`/`<animate>` 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('<iframe src=\"https://www.youtube.com/embed/x\" srcdoc=\"<b>MARK</b>\"></iframe>'))\nprint(c_svg.clean_html('<svg><a><set attributename=\"href\" to=\"javascript:MARK\"></set><text>x</text></a></svg>'))\nprint(c_svg.clean_html('<svg><a><animate attributename=\"href\" values=\"javascript:MARK\"></animate><text>x</text></a></svg>'))\n# controls, same configurations\nprint(c_svg.clean_html('<svg><a href=\"javascript:MARK\"><text>x</text></a></svg>'))\nprint(c_svg.clean_html('<svg><a onclick=\"MARK\"><text>x</text></a></svg>'))\nprint(Cleaner(host_whitelist=['www.youtube.com']).clean_html('<iframe src=\"https://www.youtube.com/embed/x\" srcdoc=\"<b>MARK</b>\"></iframe>'))\n```\n\n```text\n<iframe src=\"https://www.youtube.com/embed/x\" srcdoc=\"<b>MARK</b>\"></iframe>\n<svg><a><set attributename=\"href\" to=\"javascript:MARK\"></set><text>x</text></a></svg>\n<svg><a><animate attributename=\"href\" values=\"javascript:MARK\"></animate><text>x</text></a></svg>\n<svg><a href=\"\"><text>x</text></a></svg>\n<svg><a><text>x</text></a></svg>\n<iframe src=\"https://www.youtube.com/embed/x\"></iframe>\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 `<set>` and `<animate>`, 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 `<set>` and `<animate>`, 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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "lxml-html-clean"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.4.7"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 0.4.6"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/fedora-python/lxml_html_clean/security/advisories/GHSA-5gvf-7wqf-r4cv"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-141556"
}, {
"type" : "WEB",
"url" : "https://github.com/fedora-python/lxml_html_clean/commit/883db209e04222a1959f7773f5bde1da0224fbe1"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/fedora-python/lxml_html_clean"
}, {
"type" : "WEB",
"url" : "https://github.com/fedora-python/lxml_html_clean/releases/tag/0.4.7"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-184", "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-12-03T02:41:48Z",
"nvd_published_at" : "2026-12-02T21:18:11Z"
}
}