An external entity is an XML entity whose value points to content outside the document, such as a file, URL, or other resource. If a parser resolves it, the application may disclose information or reach systems the user should never access. Properly configured parsers should not follow these references in untrusted XML.
What External Entity Means in XML Security
An external entity is a reference that tells an XML parser to fetch content from outside the document, such as a local file, network location, or remote service. That makes it dangerous because the parser may substitute the referenced content into the XML processing flow, turning a data parsing step into an unexpected access path.
In practice, the term matters because the entity itself is not the vulnerability, the parser’s decision to resolve it is. When that happens in untrusted XML, the application can expose local data, make outbound requests, or reveal internal resources that should never be reachable through user-supplied input.
How External Entities Become an Attack Path
External entities are commonly abused through XXE, where an attacker places a crafted entity declaration into XML that the parser accepts. If the parser supports document type declarations and resolves the reference, the application may read files, make server-side requests, or disclose internal content through error messages or response bodies.
The underlying security issue is trust in parser behaviour. A parser that automatically expands external references can be coerced into performing actions the application never intended, which is why secure XML handling treats untrusted entity resolution as a control failure, not a convenience feature.
NHIMG’s XXE Guide explains how these flaws work, where XML hides them, and how secure parser settings prevent resolution.
What Security Problems External Entities Can Cause
The most serious consequences are information disclosure and server-side request abuse. A resolved external entity can expose configuration files, credentials, metadata endpoints, or internal network responses if the parser is allowed to follow file or URL references.
External entities can also be used to probe internal systems indirectly, which makes them relevant to broader web application attack chains. In some environments, the parser may also spend resources retrieving or expanding referenced content, which can amplify load or trigger secondary parser failures.
NHIMG’s Web Application Attacks Guide places XXE alongside other web injection and request-abuse patterns, helping readers understand how it fits into real application attack paths.
How to Prevent and Detect External Entity Abuse
The safest approach is to disable external entity resolution and any unnecessary DTD processing in parsers that handle untrusted input. Where XML is unavoidable, parser configuration should be explicit, tested, and consistent across languages and services so one weak component does not reopen the same exposure.
Detection is usually indirect: look for parser errors involving DTDs, unexpected outbound fetches from XML-processing components, and application behaviour that changes when malicious XML is supplied. After a suspected XXE event, review whether the parser accessed local files, internal endpoints, or secret-bearing configuration sources.
NHIMG’s OWASP Top 10 A02 Guide is useful here because XXE often appears as a security misconfiguration problem, especially when parser defaults are left unchanged.
Risk and Threat Considerations
External entities are risky because they convert XML parsing into a potential read or request primitive. In untrusted-input paths, that can expose files, internal services, or metadata that should remain isolated from the application user.
Failure mechanism: The parser resolves a crafted entity reference and substitutes the external content into application processing, allowing data exfiltration or server-side request abuse.
Impact: Attackers can disclose sensitive data, map internal resources, or pivot into follow-on abuse if the resolved content influences application output or downstream requests.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
CIS Controls v8, OWASP ASVS and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| CIS Controls v8 | CIS-16 — Application Software Security | XXE is a parser-level application security flaw requiring secure input handling. |
| Recommendation — Harden XML processing and test parser settings to prevent entity resolution in untrusted input. | ||
| OWASP ASVS | V1 — Encoding and Sanitization | ASVS V1 covers input handling and parser safety relevant to XXE prevention. |
| V13 — Configuration | XXE commonly persists through unsafe default parser configuration. | |
| Recommendation — Validate and sanitize XML input so external entity references cannot be resolved. Disable DTD processing and external entity resolution in XML parser configuration. | ||
| NIST SP 800-53 Rev 5 | SI-10 — Information Input Validation | XXE is prevented by controlling how externally supplied XML is parsed and accepted. |
| SC-18 — Mobile Code | SC-18 is the closest control for restricting executable or externally sourced content interpreted by software components. | |
| Recommendation — Apply input-validation controls to reject XML structures that enable unsafe entity expansion. Restrict parser behaviour so externally referenced content cannot be executed or expanded implicitly. | ||
Related resources from NHI Mgmt Group
- How should security teams contain XML external entity risk in document processing pipelines that accept untrusted files?
- How should Go teams prevent XML external entity attacks in applications that parse untrusted XML?
- What is the difference between external entity resolution and entity expansion in XML security?
- How should Django teams prevent XML External Entity attacks when parsing untrusted XML?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org