CVE-2026-28350: lxml-html-clean has <base> tag injection through default Cleaner configuration
Summary The tag passes through the default Cleaner configuration. While pagestructure=True removes html, head, and title tags, there is no specific handling for , allowing an attacker to inject it and hijack relative links on the page. Details The tag is not currently in the pagestructure kill set. Even though the specification says must be inside , browsers accept tags outside of the head.
Published Mar 2, 2026 · Updated Mar 5, 2026
Affected packages
lxml-html-clean
- Ecosystem
- PyPI
- Affected
- <= 0.4.3
- Fixed in
- 0.4.4
- Check
pip show lxml-html-clean
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
The <base> tag passes through the default Cleaner configuration. While page_structure=True removes html, head, and title tags, there is no specific handling for <base>, allowing an attacker to inject it and hijack relative links on the page.
Details
The <base> tag is not currently in the page_structure kill set. Even though the specification says <base> must be inside <head>, browsers accept <base> tags outside of the head.
If an attacker injects a <base> tag, it changes the base URL for all relative URLs on the page (links, images, scripts) to a domain controlled by the attacker.
PoC
from lxml_html_clean import clean_html
# The base tag is preserved in the output
result = clean_html('<base href="http://evil.com/">Account')
print(result)
# Output: <base href="http://evil.com/">...AccountImpact
The injection of a <base> tag allows an attacker to hijack the resolution of all relative URLs on the page. This results in three critical attack vectors:
- Phishing & Redirection: Attackers can redirect user navigation (e.g., `
) and form submissions (e.g.,`) to an attacker-controlled domain, effectively stealing credentials or sensitive data without the user realizing they have left the legitimate site. - Cross-Site Scripting (XSS): If the victim application loads JavaScript files using relative paths (e.g.,
<script src="assets/app.js">), the browser will attempt to fetch the script from the attacker's domain. This upgrades the vulnerability from HTML injection to full Stored XSS. - Defacement: Relative references to images (`
) and stylesheets (`) will be loaded from the attacker's server, allowing for UI redressing or defacement.
Credited to uug4na, frenzymadness, befeleme.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
