/

CVE-2026-41066

Severity:

HIGH RISK

(7.5)

XML External Entity (XXE) in Python lxml Parsers

CVE-2026-41066

Analyzed

Vulnerability type

Category:

XML External Entity (XXE)

CWE:

CWE-611

Impact:

Data Exposure via Local File Read

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A default configuration issue in the Python lxml XML/HTML parsers can allow untrusted XML input to access local files via external entity resolution.

When applications parse attacker-controlled XML without disabling entity resolution, the parser may expose sensitive file contents from the host system.

Affected context

This vulnerability affects Python applications that use lxml to parse XML or HTML with its default parser configuration, where resolve_entities=True.

It becomes relevant when:

  • XML/HTML content is derived from untrusted or partially trusted sources (e.g., HTTP requests, uploaded files, third‑party integrations), and
  • The application does not explicitly restrict entity resolution (e.g., resolve_entities='internal' or resolve_entities=False), and
  • The environment hosts sensitive files accessible to the lxml process (keys, configuration, tokens, etc.).

Exploit preconditions

  • Attack surface: Any lxml-based XML/HTML parsing endpoint or feature that accepts user-supplied or externally sourced XML.
  • Required access: Ability to submit or influence XML content processed by lxml (e.g., request body, uploaded file, message queue payload).
  • Trigger point: XML parsing performed with lxml's default parsers where resolve_entities=True.
  • Why exploitation is possible: Entity resolution is enabled by default, allowing external or local entity references in XML to be expanded and read by the parser, violating the intended isolation between XML content and host resources.

Why this happens

The underlying problem is an unsafe XML parsing configuration that permits unrestricted entity resolution when handling untrusted data.

With resolve_entities=True, lxml allows XML documents to define and expand entities that reference local files or external resources.

This maps to CWE-611: Improper Restriction of XML External Entity Reference, where the XML parser is not hardened against malicious entity declarations and treats attacker-controlled XML as trustworthy enough to access local resources.

Potential impact

  • Exposure of sensitive local files, such as application configuration, credentials, or secret keys.
  • Disclosure of system information that can aid further attacks (e.g., file paths, environment details).
  • Access to logs or internal data files that may contain user information or operational metadata.
  • Facilitation of chained attacks, where leaked secrets enable lateral movement or privilege escalation in the broader environment.

General mitigation guidance

Effective mitigation focuses on hardening XML parsing behavior and tightening trust boundaries around input:

  • Configure lxml parsers to disable or strictly restrict entity resolution, for example by setting resolve_entities=False or using an equivalent internal-only mode where appropriate.
  • Prefer parser configurations and APIs that are secure by default for untrusted XML, avoiding generic "full-featured" parsers on external input.
  • Limit the exposure of sensitive files and credentials on systems that handle untrusted parsing workloads; apply least-privilege file and process permissions.
  • Where possible, avoid XML features that rely on custom entities for untrusted content, and use simpler data formats (e.g., JSON) for external interactions.

How teams detect issues like this

Organizations can identify and monitor for this class of issue through a combination of review and analysis:

  • Static analysis & configuration review: Search for lxml parser usage where resolve_entities is left default or explicitly set to a permissive mode when handling untrusted input.
  • Code review signals: XML parsing logic that directly processes request bodies, uploaded files, or third-party XML without a hardened parser configuration should be flagged for security review.
  • Policy enforcement: Introduce coding guidelines and CI checks that require secure XML parsing settings for all XML-handling components.
  • Runtime monitoring: Where feasible, monitor application behavior for unusual file access patterns correlated with XML parsing operations.

Sources

SourceLink
bugs.launchpad.netbugs.launchpad.net/lxml/+bug/2146291
github.comgithub.com/lxml/lxml/security/advisories/GHSA-vfmq-68hx-4jfw

Frequently asked

questions

Yes, if an attacker can submit or influence XML content that the application parses with lxml's default configuration, they may be able to read local files via crafted entity declarations.

The attacker generally needs only the ability to provide XML input to the application—such as through HTTP requests, file uploads, or integration endpoints—without needing direct filesystem access or local accounts.

Use hardened XML parser settings for any untrusted input: disable or restrict entity resolution (e.g., resolve_entities=False or equivalent), and ensure all XML parsing code paths follow this pattern consistently.

Adopt secure defaults for XML parsing across the codebase, document approved parser configurations, enforce them through code review and automated checks, and favor simpler, less feature-rich formats or libraries for handling untrusted data.

Find out what's already
exploitable in your codebase.