Join our Newsletter — 33% off our NHI Course

External Entity Loading

The parser behavior that allows XML documents to resolve entity references from external locations, such as URLs or local file paths. If this capability is enabled for untrusted XML, it can expose files, trigger outbound requests, and create a broad data-exfiltration path. Secure XML handling disables it by default.

How External Entity Loading Works

external entity loading is a parser feature in XML that resolves entity references by fetching content from locations outside the document, including URLs, file paths, or other reachable resources. It is part of how some XML parsers expand references during document processing, rather than a separate transport or file-access feature.

The behavior matters because the parser is acting on behalf of the XML document, not the user. If the parser is allowed to dereference external content from untrusted input, the document can reach beyond its own contents and pull in data from places the application did not intend to expose.

That makes the term especially important in secure XML handling. The same parser capability that enables modular document composition can become a trust-boundary problem when it is left on for untrusted or attacker-supplied XML.

Why It Becomes Dangerous in Untrusted XML

The central security issue is that external entity resolution can create unintended read and network channels. A malicious XML payload may attempt to reference local files, internal services, or remote URLs, turning a routine parse step into a data exposure path or an outbound request primitive.

This is why secure XML parsers typically disable external entity resolution by default or provide explicit hardening settings. The risk is not limited to one file being read, it is the parser’s ability to reach resources the application never explicitly approved.

In practice, the danger is strongest when XML is accepted from users, partners, message buses, or other untrusted sources and then parsed automatically. The parser may follow references long before the application logic has any chance to inspect them.

Common Failure Modes

External entity loading fails when security controls assume XML parsing is passive. Developers may validate the document structure but overlook parser defaults, allowing external references to resolve anyway. The failure often appears as a configuration gap rather than an obvious coding bug.

Another failure mode is inconsistent parser behavior across libraries, runtimes, or services. One component may block external entities while another allows them, which creates uneven exposure and makes security testing harder.

Because the behavior can involve both file access and outbound requests, it can also confuse incident investigation. What looks like ordinary XML processing may actually be the first step in a data-exfiltration or server-side request path.

Secure Handling and Control Points

Secure handling starts by treating external entity resolution as unnecessary unless a specific, trusted use case demands it. The default stance should be to keep it disabled for untrusted input, then enable only with tightly defined scope where the parser and deployment environment are both controlled.

It also helps to separate XML parsing from privileged access to files and network destinations. Even if a parser can resolve entities, the surrounding runtime should not give it broad filesystem reach or unfettered outbound connectivity.

When XML remains part of the system, threat modeling should account for how entity expansion interacts with parser defaults, validation logic, and downstream network visibility. The useful question is not whether XML is supported, but whether the parser is permitted to fetch anything outside the document.

Risk and Threat Considerations

External entity loading can expose local files, internal services, and metadata through a parser that follows attacker-controlled references. It is a classic trust-boundary problem because the parser may be allowed to reach resources the application never intended to disclose.

Failure mechanism: An attacker supplies XML that contains external entity references, and the parser resolves them during document processing, creating file-read or outbound-request behavior that can leak data or reveal internal network responses.

Impact: The result can include sensitive file disclosure, server-side request activity, internal service probing, and broader exfiltration paths that are hard to spot because they occur inside normal parsing flows.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP ASVS and NIST SP 800-53 Rev 5 set the technical controls, while ISO/IEC 27001:2022 defines the regulatory obligations.

Framework Control / Reference Relevance
OWASP ASVS V1 — Encoding and Sanitization XML entity handling is an input parsing and sanitization concern.
Recommendation — Validate XML input handling so external entities cannot expand into unsafe parser behavior.
NIST SP 800-53 Rev 5 SI-10 — Information Input Validation External entity loading is controlled through safe validation of parsed input.
AC-4 — Information Flow Enforcement Entity resolution can create unintended information flows to files and network targets.
Recommendation — Harden XML parsers so untrusted input cannot trigger external entity resolution. Restrict XML processing paths so parsers cannot disclose data through external references.
ISO/IEC 27001:2022 A.8.9 — Configuration management Parser settings must be securely configured to disable risky XML features.
Recommendation — Set secure XML parser defaults and review configurations as part of hardening.

Practitioner Guidance

What to watch for: Treat parser defaults as a security decision, not an implementation detail. If your application accepts XML from outside the trust boundary, verify that external entity resolution is disabled in every parser instance, service, and language binding that can process it.

Governance implication: Security review should cover XML parser configuration as part of secure input handling, especially where legacy integrations, document workflows, or middleware may still rely on XML features that were safe only in trusted environments.

Practitioner takeaway: If untrusted XML can reach a parser, the safe assumption is that external entity loading is a liability until proven otherwise.