CVE-2024-34078: Html sanitizer Arbitrary HTML Present After Sanitization Vulnerability

HIGH
Advisory Identifier: GHSA-wvhx-q427-fgh3
Published
Advisory Summary

CVE-2024-34078 is a HIGH arbitrary html present after sanitization vulnerability (General Security Weakness) affecting Html sanitizer libraries in the PyPI ecosystem. The issue involves arbitrary html present after sanitization because of unicode normalization. Remediation is available by upgrading affected packages to version 2.4.2.

CVE-2024-34078 at a Glance

CVE Identifier CVE-2024-34078
GHSA Identifier GHSA-wvhx-q427-fgh3
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product Html sanitizer
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2024-34078

To remediate this vulnerability, upgrade all affected Html sanitizer dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

html-sanitizer fixed: 2.4.2
pip install html-sanitizer>=2.4.2
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 html-sanitizer

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-34078, inspect your installed packages using pip:

pip show html-sanitizer

Analyze the terminal output to locate any version of Html sanitizer in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.4.2), your application is affected.

Note: The pip show html-sanitizer command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under General Security Weakness. In Html sanitizer, 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

### Impact If using `keep_typographic_whitespace=False` (which is the default), the sanitizer normalizes unicode to the NFKC form at the end. Some unicode characters normalize to chevrons; this allows specially crafted HTML to escape sanitization. ### Patches The problem has been fixed in 2.4.2. ### Workarounds Set `keep_typographic_whitespace=True` explicitly, or normalize to NFKC yourself earlier.

CVE-2024-34078 Affected Html sanitizer Versions

1 component(s)
Fixed Versions:
2.4.2
Product / Package Ecosystem Affected Versions Fixed Version
html-sanitizer
PyPI
< 2.4.2
2.4.2

References

Frequently Asked Questions

What is CVE-2024-34078?
CVE-2024-34078 is a security vulnerability in Html sanitizer involving Arbitrary HTML present after sanitization because of unicode normalization under General Security Weakness.
Which Html sanitizer versions are affected?
Affected versions include releases prior to 2.4.2 across affected packages: html-sanitizer.
What version fixes CVE-2024-34078?
Upgrading to 2.4.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is html-sanitizer affected?
Yes, html-sanitizer is affected in releases prior to 2.4.2. Upgrade your dependency to 2.4.2 or later.
What CWE is associated with CVE-2024-34078?
CVE-2024-34078 is classified under General Security Weakness.
How can I check PyPI dependencies for CVE-2024-34078?
Run the dependency tree command: 'pip show html-sanitizer'. 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-wvhx-q427-fgh3",
  "modified" : "2024-05-06T14:33:32Z",
  "published" : "2024-05-06T14:33:32Z",
  "aliases" : [ "CVE-2024-34078" ],
  "summary" : "Arbitrary HTML present after sanitization because of unicode normalization",
  "details" : "### Impact\n\nIf using `keep_typographic_whitespace=False` (which is the default), the sanitizer normalizes unicode to the NFKC form at the end. Some unicode characters normalize to chevrons; this allows specially crafted HTML to escape sanitization.\n\n### Patches\n\nThe problem has been fixed in 2.4.2.\n\n### Workarounds\n\nSet `keep_typographic_whitespace=True` explicitly, or normalize to NFKC yourself earlier.\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "html-sanitizer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.4.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/matthiask/html-sanitizer/security/advisories/GHSA-wvhx-q427-fgh3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/matthiask/html-sanitizer/commit/48db42fc5143d0140c32d929c46b802f96913550"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/matthiask/html-sanitizer"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-05-06T14:33:32Z",
    "nvd_published_at" : null
  }
}