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

lxml-html-clean Updated 02 Oct 2025

Summary

19/11/2024
N/A
Yes i
Unrated
Not published

DEBIAN-CVE-2024-52595: lxml_html_clean is a project for HTML cleaning functionalities copied from lxml.html.clean. Affects lxml-html-clean versions < 0.4.1-1. 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 Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

lxml-html-clean is a project designed for HTML cleaning functionalities, derived from the lxml.html.clean module. It provides users with the ability to sanitize untrusted HTML content, ensuring that potentially harmful scripts are removed. However, prior to version 0.4.0, the package exhibited vulnerabilities in handling special HTML tags such as <svg>, <math>, and <noscript>, which could lead to security risks.

Vulnerability Detail

The vulnerability arises from the HTML Parser in lxml, which fails to manage context-switching for specific HTML tags correctly. This inconsistency diverges from standard web browser behavior, allowing content within CSS comments to be ignored by lxml-html-clean while potentially being interpreted differently by browsers. Consequently, this could enable malicious scripts to bypass the cleaning process, leading to Cross-Site Scripting (XSS) attacks that compromise user security when relying on lxml-html-clean for sanitization.

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 mitigation, users can configure lxml-html-clean with specific settings to prevent exploitation of this vulnerability. For example, you can specify tags to remove using the 'remove_tags' option, which moves their content to parent tags. Additionally, you can use 'kill_tags' to completely remove specified tags and 'allow_tags' to restrict 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 if not addressed. Users are strongly encouraged to upgrade to the patched version and consider implementing the suggested workarounds to enhance security. Regular monitoring for vulnerabilities using tools like Vulert can help maintain application safety.

See every vulnerability recorded for lxml-html-clean →

Share this vulnerability

FAQ

The vulnerability allows malicious scripts to bypass the cleaning process due to improper handling of special HTML tags, leading to potential XSS attacks.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

Upgrade to lxml-html-clean version 0.4.1-1 or later using your package manager to ensure that the vulnerability is patched.

Yes, you can configure lxml-html-clean with settings to remove or restrict certain tags to mitigate the risk temporarily.

Failure to address this vulnerability could expose users to XSS attacks, compromising their security and the integrity of the application.

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