PyPI: lxml
CVE-2026-41066
Safety vulnerability ID: SFTY-20260421-23679
Safety legacy ID: pyup.io-94243
Affected versions of the lxml package are vulnerable to XML External Entity Injection due to insecure default parser configuration that resolves external entities. The iterparse() function and the ETCompatXMLParser() class both default to resolve_entities=True, so untrusted XML input processed through either parser will expand external entity references and read referenced local files from the host. An attacker who supplies a crafted XML document to an application using these parsers in their default configuration can read sensitive local files and exfiltrate their contents through the parsed output.
Overview
lxml: Default configuration of iterparse() and ETCompatXMLParser() allows XXE to local files
Advisory
Affected versions of the lxml package are vulnerable to XML External Entity Injection due to insecure default parser configuration that resolves external entities. The iterparse() function and the ETCompatXMLParser() class both default to resolve_entities=True, so untrusted XML input processed through either parser will expand external entity references and read referenced local files from the host. An attacker who supplies a crafted XML document to an application using these parsers in their default configuration can read sensitive local files and exfiltrate their contents through the parsed output.
How to Fix
Mitigation and Workarounds
---
Vulnerable Functions
Functions linked to known vulnerabilities.
References
- https://getsafety.com/vulnerabilities/SFTY-20260421-23679/CVE-2026-41066
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2026-41066
- https://data.safetycli.com/changelogs/lxml/
- https://github.com/advisories/GHSA-vfmq-68hx-4jfw
- https://pypi.org/project/lxml
- https://github.com/lxml/lxml/security/advisories/GHSA-vfmq-68hx-4jfw
- https://bugs.launchpad.net/lxml/+bug/2146291
- https://github.com/lxml/lxml/releases/tag/lxml-6.1.0
- https://nvd.nist.gov/vuln/detail/CVE-2026-41066
- https://github.com/advisories/GHSA-vfmq-68hx-4jfw
Verified by Safety
Our Cybersecurity Intelligence Team reviewed this vulnerability. We combine public data with our own research to find issues not yet reported to public sources.
Learn more
