CVE-2026-49825: lxml-html-clean - XSS Vulnerability Due to Incomplete URL Scheme Filtering
Summary
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 ↓
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.
No signup required · Results in about 60 seconds
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 →
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.
References
Related vulnerabilities
Recent vulnerabilities recorded for lxml-html-clean.
Follow Vulert in Google
Get more Vulert vulnerability and dependency-security updates in Google Search and AI results.