# CVE-2024-52595: HTML Cleaner allows crafted scripts in special contexts like svg or math to pass through

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.7
- **CVSS:** 7.7 (v3.1, CNA) `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:H`
- **CVSS metrics:** Attack vector: Network; Attack complexity: High; Privileges required: None; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: Low; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, no login needed
- **EPSS:** 0.96% (percentile 60, 2026-11-26)
- **CWE:** CWE-79, CWE-83, CWE-184
- **Aliases:** GHSA-5jfw-gq64-q45f, PYSEC-2024-160
- **Published:** 2024-11-19T21:07:59.000Z
- **Modified:** 2026-06-17T08:07:31.003Z

## Who should check

- Projects that depend on PyPI package lxml-html-clean (\< 0.4.0)
- Anyone running fedora-python lxml\_html\_clean \< 0.4.0

## Description

lxml\_html\_clean is a project for HTML cleaning functionalities copied from \`lxml.html.clean\`. Prior to version 0.4.0, the HTML Parser in lxml does not properly handle context-switching for special HTML tags such as \`\<svg\>\`, \`\<math\>\` and \`\<noscript\>\`. This behavior deviates from how web browsers parse and interpret such tags. Specifically, content in CSS comments is ignored by lxml\_html\_clean but may be interpreted differently by web browsers, enabling malicious scripts to bypass the cleaning process. This vulnerability could lead to Cross-Site Scripting (XSS) attacks, compromising the security of users relying on lxml\_html\_clean in default configuration for sanitizing untrusted HTML content. Users employing the HTML cleaner in a security-sensitive context should upgrade to lxml 0.4.0, which addresses this issue. As a temporary mitigation, users can configure lxml\_html\_clean with the following settings to prevent the exploitation of this vulnerability. Via \`remove\_tags\`, one may specify tags to remove - their content is moved to their parents' tags. Via \`kill\_tags\`, one may specify tags to be removed completely. Via \`allow\_tags\`, one may restrict the set of permissible tags, excluding context-switching tags like \`\<svg\>\`, \`\<math\>\` and \`\<noscript\>\`.

## Affected and fixed versions

- PyPI `lxml-html-clean`: affected \< 0.4.0; fixed 0.4.0 (osv)
- fedora-python lxml\_html\_clean: \< 0.4.0 (cvelist)

## Mitigation

- Upgrade lxml-html-clean to 0.4.0 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2024-52595. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-52595.md
Affected: lxml-html-clean < 0.4.0
Fixed in: 0.4.0

Steps:
1. Search this machine and project for lxml-html-clean (PyPI), fedora-python lxml_html_clean: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2024-52595 being exploited?

There is no confirmed exploitation: CVE-2024-52595 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.96% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2024-52595?

High: CVSS 7.7 (v3.1, scored by CNA). Remote, no login needed. The attack needs conditions outside the attacker's control, which makes it harder.

### Which versions are affected by CVE-2024-52595?

lxml-html-clean \< 0.4.0.

### Is there a fix for CVE-2024-52595?

Yes. Fixed in 0.4.0. Upgrade lxml-html-clean to 0.4.0 or later.

### How do I check if I'm affected by CVE-2024-52595?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/fedora-python/lxml_html_clean/security/advisories/GHSA-5jfw-gq64-q45f>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2024-52595>
- patch: <https://github.com/fedora-python/lxml_html_clean/pull/19>
- patch: <https://github.com/fedora-python/lxml_html_clean/commit/c5d816f86eb3707d72a8ecf5f3823e0daa1b3808>
- other: <https://github.com/fedora-python/lxml_html_clean>
- other: <https://github.com/pypa/advisory-database/tree/main/vulns/lxml-html-clean/PYSEC-2024-160.yaml>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2024-52595>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-5jfw-gq64-q45f> (license: <https://creativecommons.org/licenses/by/4.0/>)
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/PYSEC-2024-160> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2024-52595> · JSON: <https://flawdb.com/api/v1/entries/CVE-2024-52595>
