Cross-Site Scripting Vulnerability in lxml-html-clean Package

lxml-html-clean Updated 02 Oct 2025

Summary

19/11/2024
N/A
Yes i
Medium
6.1

CVE-2024-52595: lxml_html_clean is a project for HTML cleaning functionalities copied from lxml.html.clean. Affects lxml-html-clean across 2 version ranges.

< 0.4.1-1 < c5d816f86eb3707d72a8ecf5f3823e0daa1b3808

Fixed in 0.4.1-1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

lxml-html-clean is a project that provides HTML cleaning functionalities derived from lxml.html.clean. It is designed to sanitize untrusted HTML content, making it safer for use in web applications. However, prior to version 0.4.0, the package exhibited issues with handling special HTML tags like <svg>, <math>, and <noscript>, which could lead to security vulnerabilities.

Vulnerability Detail

The vulnerability arises from the HTML Parser in lxml, which fails to properly manage context-switching for certain HTML tags. This deviation from standard web browser behavior allows malicious scripts to bypass the cleaning process, potentially leading to Cross-Site Scripting (XSS) attacks. Users relying on lxml-html-clean for sanitizing HTML content may inadvertently expose themselves to security risks if they do not upgrade to the patched version.

How To Fix

Minimum fixed version

0.4.1-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade lxml-html-clean

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary measure, users can configure lxml-html-clean with specific settings to mitigate the risk. For instance, you can use the following configurations:

  • remove_tags: Specify tags to remove, moving their content to their parent tags.
  • kill_tags: Specify tags to be completely removed.
  • allow_tags: Restrict the set of permissible tags, excluding context-switching tags like <svg>, <math>, and <noscript>.

Conclusion

The lxml-html-clean package has a significant vulnerability that can lead to XSS attacks due to improper handling of special HTML tags. Users are strongly advised to upgrade to the latest version to ensure their applications remain secure. Temporary workarounds are available for those unable to upgrade immediately.

See every vulnerability recorded for lxml-html-clean →

Share this vulnerability

FAQ

The vulnerability is a Cross-Site Scripting (XSS) issue that allows malicious scripts to bypass the HTML cleaning process.

You can check if your application is affected by using the Vulert playground at Vulert Scanner, which allows you to monitor for open-source vulnerabilities without needing to sign up.

If exploited, this vulnerability could compromise the security of users by allowing attackers to execute malicious scripts in the context of the application.

Yes, a patch is available in version 0.4.1-1 of lxml-html-clean. Users should upgrade to this version or later.

If an immediate upgrade is not possible, implement the suggested workarounds to mitigate the risk until you can update.

Related vulnerabilities

Recent vulnerabilities recorded for lxml-html-clean.

How To Fix

Minimum fixed version

0.4.1-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade lxml-html-clean

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback