CVE-2026-49825: lxml-html-clean - XSS Vulnerability Due to Incomplete URL Scheme Filtering

lxml-html-clean Updated 18 Jul 2026

Summary

08/07/2026
Yes i
High
8.2

CVE-2026-49825: lxml_html_clean.Cleaner does not strip javascript: URLs from namespaced URL attributes. Affects lxml-html-clean versions < 0.4.5. Fixed in 0.4.5. 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 Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

lxml-html-clean is a Python package that provides a cleaner for HTML content, allowing developers to sanitize untrusted HTML input. It is commonly used to prevent cross-site scripting (XSS) attacks by filtering out potentially dangerous elements and attributes. However, certain configurations of the Cleaner class can lead to vulnerabilities if not properly managed, particularly with namespaced URL attributes.

Vulnerability Detail

The vulnerability arises from the lxml_html_clean.Cleaner not stripping 'javascript:' URLs from namespaced URL attributes such as 'xlink:href'. This issue is rooted in the implementation of the Cleaner, which relies on a predefined allow-list of attributes that does not include namespaced attributes. As a result, when the Cleaner is configured with 'safe_attrs_only=False', malicious payloads can pass through the sanitizer, leading to stored XSS vulnerabilities. This flaw can be exploited when a user clicks on a rendered link, executing the embedded JavaScript in the context of the application.

How To Fix

Minimum fixed version

0.4.5

This is the first release that contains the fix.

pip install --upgrade "lxml-html-clean==0.4.5"

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

Workaround

As an immediate workaround, you can manually extend the Cleaner class to include a check for namespaced URL attributes. Here is a code snippet to implement this workaround:

from lxml import html
from lxml_html_clean import Cleaner
import re

class CustomCleaner(Cleaner):
    def __call__(self, doc):
        super().__call__(doc)
        for el in doc.iter():
            if 'xlink:href' in el.attrib:
                if re.match(r'^\s*(javascript|vbscript|data):', el.attrib['xlink:href'], re.I):
                    del el.attrib['xlink:href']

This custom cleaner will remove any 'javascript:' URLs from 'xlink:href' attributes.

Conclusion

The CVE-2026-49825 vulnerability in lxml-html-clean poses a significant risk of XSS attacks due to improper handling of namespaced URL attributes. It is crucial for developers to update to the patched version or implement a workaround to mitigate this risk.

See every vulnerability recorded for lxml-html-clean →

Share this vulnerability

FAQ

CVE-2026-49825 is a security vulnerability in the lxml-html-clean package that allows for XSS attacks due to improper filtering of namespaced URL attributes.

You can check if your application is affected by using the Vulert playground at Vulert Scanner, which monitors open-source vulnerabilities in real-time.

The CVSS score for this vulnerability is 8.2, indicating a high severity level.

If you cannot update the package, implement the provided workaround to manually filter out 'javascript:' URLs from namespaced attributes.

Yes, the vulnerability affects all versions of lxml-html-clean up to and including 0.4.4. The issue is resolved in version 0.4.5 and later.

Related vulnerabilities

Recent vulnerabilities recorded for lxml-html-clean.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Minimum fixed version

0.4.5

This is the first release that contains the fix.

pip install --upgrade "lxml-html-clean==0.4.5"

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

Follow Vulert in Google

Get more Vulert vulnerability and dependency-security updates in Google Search and AI results.