Home/Research/Post

GHSA-5gvf-7wqf-r4cv: lxml_html_clean: Cleaner(safe_attrs_only=False) keeps javascript: in iframe srcdoc and SVG animation values

  • Severity: MEDIUM
  • CVE: CVE-2026-141556
  • Ecosystems: pip
  • Packages: lxml-html-clean

## 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:

1. `srcdoc` on “. Its value is a complete HTML document that the browser renders inside the frame. With `host_whitelist` set, the “ itself is kept, and `srcdoc` takes priority over `src`, so the whitelisted `src` no longer matters.
2. `to`, `values` (and `from`, `by`) on the SVG animation elements “ and “. With `attributeName=”href”` they set the `href` of the enclosing SVG “ 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 “/“ 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…

Source: GitHub Security Advisories · 2026-12-03