CVE-2026-141556
lxml- html- clean: Cleaner(safe_ attrs_ only=False) keeps javascript: in iframe srcdoc and SVG animation values (PyPI)
- Severity
- 4.7MediumNetwork attack, no privileges, needs user interactionCVSS 3.1, CVE List
- Exploitation
- Proof of conceptCISA reports one, no source links it
- Exploit chance
- 0.39% in 30 daysPercentile35thEPSS, scored
- Listed fix
0.4.7for lxml-html- clean From GitHub Advisories and OSV
Overview
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.
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:NExploit chance over time
Affected
Packages 1
| Package | Affected | Fixed |
|---|---|---|
lxml-html-cleanPyPI | 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 less0.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(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values
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.
- Record
CVE-2026-141556- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Weakness
- CWE-79, CWE-184
- Updated
- 2026-12-05
EUVDEUVD-2026-141834CVSS 3.14.7
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.
- Record
EUVD-2026-141834- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Updated
- 2026-12-05
GitHub AdvisoriesGHSA-5gvf-7wqf-r4cvCVSS 3.14.7
lxml_html_clean: Cleaner(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values
Summary
When 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:
srcdocon<iframe>. Its value is a complete HTML document that the browser renders inside the frame. Withhost_whitelistset, the<iframe>itself is kept, andsrcdoctakes priority oversrc, so the whitelistedsrcno longer matters.to,values(andfrom,by) on the SVG animation elements<set>and<animate>. WithattributeName="href"they set thehrefof the enclosing SVG<a>at runtime, sojavascript:ends up on the link even though the Cleaner removed it fromhrefitself. This one also needsremove_unknown_tags=False, otherwise<set>/<animate>are dropped.
This 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.
The default Cleaner() is not affected: safe_attrs_only=True removes srcdoc, to and values.
Affected versions
Cleaner 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.
Reproduction
from lxml_html_clean import Cleaner
c_ifr = Cleaner(host_whitelist=['www.youtube.com'], safe_attrs_only=False)
c_svg = Cleaner(safe_attrs_only=False, remove_unknown_tags=False)
print(c_ifr.clean_html('<iframe src="https://www.youtube.com/embed/x" srcdoc="<b>MARK</b>"></iframe>'))
print(c_svg.clean_html('<svg><a><set attributename="href" to="javascript:MARK"></set><text>x</text></a></svg>'))
print(c_svg.clean_html('<svg><a><animate attributename="href" values="javascript:MARK"></animate><text>x</text></a></svg>'))
# controls, same configurations
print(c_svg.clean_html('<svg><a href="javascript:MARK"><text>x</text></a></svg>'))
print(c_svg.clean_html('<svg><a onclick="MARK"><text>x</text></a></svg>'))
print(Cleaner(host_whitelist=['www.youtube.com']).clean_html('<iframe src="https://www.youtube.com/embed/x" srcdoc="<b>MARK</b>"></iframe>'))
<iframe src="https://www.youtube.com/embed/x" srcdoc="<b>MARK</b>"></iframe>
<svg><a><set attributename="href" to="javascript:MARK"></set><text>x</text></a></svg>
<svg><a><animate attributename="href" values="javascript:MARK"></animate><text>x</text></a></svg>
<svg><a href=""><text>x</text></a></svg>
<svg><a><text>x</text></a></svg>
<iframe src="https://www.youtube.com/embed/x"></iframe>
Browser 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.
Impact
Stored 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.
Suggested fix
In the if self.javascript: block of Cleaner.__call__:
- delete
srcdocfrom every element; -…
- Record
GHSA-5gvf-7wqf-r4cv- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Weakness
- CWE-79, CWE-184
- Updated
- 2026-12-03
NVDCVSS 3.14.7
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.
- Record
CVE-2026-141556- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Weakness
- CWE-79, CWE-184
- Updated
- 2026-12-05
OSVCVSS 3.14.7
lxml-html-clean: Cleaner(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values
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.
- Record
CVE-2026-141556- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Weakness
- CWE-184, CWE-79
- Updated
- 2026-12-03
OSVGHSA-5gvf-7wqf-r4cvCVSS 3.14.7
lxml_html_clean: Cleaner(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values
Summary
When 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:
srcdocon<iframe>. Its value is a complete HTML document that the browser renders inside the frame. Withhost_whitelistset, the<iframe>itself is kept, andsrcdoctakes priority oversrc, so the whitelistedsrcno longer matters.to,values(andfrom,by) on the SVG animation elements<set>and<animate>. WithattributeName="href"they set thehrefof the enclosing SVG<a>at runtime, sojavascript:ends up on the link even though the Cleaner removed it fromhrefitself. This one also needsremove_unknown_tags=False, otherwise<set>/<animate>are dropped.
This 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.
The default Cleaner() is not affected: safe_attrs_only=True removes srcdoc, to and values.
Affected versions
Cleaner 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.
Reproduction
from lxml_html_clean import Cleaner
c_ifr = Cleaner(host_whitelist=['www.youtube.com'], safe_attrs_only=False)
c_svg = Cleaner(safe_attrs_only=False, remove_unknown_tags=False)
print(c_ifr.clean_html('<iframe src="https://www.youtube.com/embed/x" srcdoc="<b>MARK</b>"></iframe>'))
print(c_svg.clean_html('<svg><a><set attributename="href" to="javascript:MARK"></set><text>x</text></a></svg>'))
print(c_svg.clean_html('<svg><a><animate attributename="href" values="javascript:MARK"></animate><text>x</text></a></svg>'))
# controls, same configurations
print(c_svg.clean_html('<svg><a href="javascript:MARK"><text>x</text></a></svg>'))
print(c_svg.clean_html('<svg><a onclick="MARK"><text>x</text></a></svg>'))
print(Cleaner(host_whitelist=['www.youtube.com']).clean_html('<iframe src="https://www.youtube.com/embed/x" srcdoc="<b>MARK</b>"></iframe>'))
<iframe src="https://www.youtube.com/embed/x" srcdoc="<b>MARK</b>"></iframe>
<svg><a><set attributename="href" to="javascript:MARK"></set><text>x</text></a></svg>
<svg><a><animate attributename="href" values="javascript:MARK"></animate><text>x</text></a></svg>
<svg><a href=""><text>x</text></a></svg>
<svg><a><text>x</text></a></svg>
<iframe src="https://www.youtube.com/embed/x"></iframe>
Browser 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.
Impact
Stored 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.
Suggested fix
In the if self.javascript: block of Cleaner.__call__:
- delete
srcdocfrom every element; -…
- Record
GHSA-5gvf-7wqf-r4cv- CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N - Weakness
- CWE-184, CWE-79
- Updated
- 2026-12-03
The JSON record also has the rest of 2 source descriptions.
History
Recorded by Every CVE
| Day | Changed | Sources |
|---|---|---|
| Published date | EUVD, NVD | |
| Key facts, references | CVE List, OSV | |
| Published date | EUVD | |
| Affected packages, references | GitHub Advisories | |
| Affected packages, key facts, references | OSV | |
| Other IDs, references | OSV | |
| Other IDs, published date | EUVD, NVD | |
| First indexed | CVE List |
Upstream dates may differ.
References
github.com/fedora-python/lxml_html_clean/security/advisories/GHSA-5gvf-7wqf-r4cv
github.com/fedora-python/lxml_html_clean/commit/883db209e04222a1959f7773f5bde1da0224fbe1
github.com/fedora-python/lxml_html_clean/releases/tag/0.4.7
nvd.nist.gov/vuln/detail/CVE-2026-141556
github.com/advisories/GHSA-5gvf-7wqf-r4cv
github.com/CVEProject/cvelistV5/tree/main/cves/2026/141xxx/CVE-2026-141556.json
github.com/fedora-python/lxml_html_clean