CVE-2026-49825: lxml-html-clean Vulnerability in URL Attribute Sanitization

lxml-html-clean Updated 18 Jul 2026

Summary

13/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 Devnack Your last release was probably never penetration tested 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 Python package that provides a cleaner for HTML content, allowing developers to sanitize untrusted HTML by removing potentially harmful elements and attributes. It is commonly used in web applications to prevent XSS (Cross-Site Scripting) attacks. The package is designed to filter out unsafe attributes and ensure that the rendered HTML is safe for users. However, a vulnerability exists in the way it handles namespaced URL attributes, specifically xlink:href, which can lead to security risks if not addressed.

Vulnerability Detail

The vulnerability arises from the lxml_html_clean.Cleaner class, which fails to strip javascript: URLs from namespaced URL attributes like xlink:href. This oversight allows malicious payloads to pass through the sanitizer when the safe_attrs_only option is set to False. As a result, an attacker can inject JavaScript code that executes when a user clicks on the rendered link, leading to stored XSS vulnerabilities. The root cause is linked to an incomplete allow-list of attributes that does not include xlink:href, which is necessary for proper sanitization.

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

If you cannot update the package immediately, you can implement a temporary workaround by manually checking and removing any xlink:href attributes containing javascript: URLs in your HTML content. Here's a code snippet to illustrate this workaround:

from lxml import html

def sanitize_xlink_href(tree):
    for el in tree.iter():
        if 'xlink:href' in el.attrib and el.attrib['xlink:href'].startswith('javascript:'):
            del el.attrib['xlink:href']

# Example usage:
html_content = '<svg><a xlink:href="javascript:alert(1)">x</a></svg>'
tree = html.fromstring(html_content)
sanitize_xlink_href(tree)
print(html.tostring(tree).decode())

Conclusion

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

See every vulnerability recorded for lxml-html-clean →

Share this vulnerability

FAQ

CVE-2026-49825 is a vulnerability in the lxml-html-clean package that allows javascript: URLs to pass through the sanitizer when using namespaced URL attributes like xlink:href.

The vulnerability can lead to stored XSS attacks, where malicious JavaScript code is executed in the context of the user's browser, potentially compromising user data and application integrity.

You can use Vulert, a tool that monitors and alerts for open-source vulnerabilities in your software. Check your application against this vulnerability using the Vulert playground at Vulert Scanner.

Implement the provided workaround to manually sanitize xlink:href attributes in your HTML content until you can update to the patched version.

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

Related vulnerabilities

Recent vulnerabilities recorded for lxml-html-clean.

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.