External entity resolution asks the parser to retrieve content from outside the document, such as a local file or internal URL, which can expose data or map the network. Entity expansion stays within the document but recursively multiplies references until the parser is overwhelmed. Both are dangerous, but one targets confidentiality and the other primarily targets availability.
How the two attacks differ in what they abuse
external entity resolution and entity expansion both exploit XML entity handling, but they attack different parts of the parser’s behaviour. External entity resolution turns the parser into a retrieval mechanism for outside content, while entity expansion turns a small document into an amplification engine. The first is about controlled or uncontrolled retrieval across a trust boundary, the second is about recursive parsing cost inside the same document.
The practical distinction matters because the parser’s action changes. With external entities, the parser may dereference a file path, local service, or internal URL and hand the response back to the application. With expansion abuse, the parser keeps expanding nested references until memory, CPU, or parser limits are exhausted. Those are different failure modes, and they often require different defensive settings.
- External entity resolution is dangerous when the parser is allowed to fetch or read content outside the XML document.
- Entity expansion is dangerous when the parser accepts recursive or repeated entity references without tight limits.
- Both become severe when applications parse untrusted XML with default or permissive settings.
Why the impact is different: confidentiality versus availability
External entity resolution primarily creates confidentiality and internal-network exposure risk. If the parser can read local files or reach internal endpoints, an attacker may exfiltrate sensitive data or use the parser as a blind probe into internal services. Entity expansion is usually an availability issue: the attacker supplies a document that looks small, but the parser spends disproportionate resources expanding it until the process slows, crashes, or times out.
That does not mean the two risks are perfectly isolated. External entity resolution can also support server-side request forgery style behaviour, and entity expansion can become a reliability problem large enough to affect upstream systems. But the core difference remains useful for triage: one asks, “What can the parser reach?”, the other asks, “How much work can the parser be forced to do?”
- When data exposure is the concern, focus on whether external resolution is enabled at all.
- When resource exhaustion is the concern, focus on entity depth, size, and expansion limits.
- When both are possible, treat the parser as untrusted input handling, not as a convenience feature.
Practical parser controls that separate the two risks
Defensive settings should be explicit rather than assumed. External entity resolution should be disabled unless there is a concrete business requirement, and parsers should be configured so they cannot read arbitrary local files or follow external network references. Entity expansion should be bounded with strict limits on recursion, entity count, and overall expansion size. Secure XML handling usually requires both controls, because stopping only one leaves a different parser abuse path open.
If your application must process XML from outside the trust boundary, use a hardened parser profile and test it with malicious samples, not just well-formed documents. Pay attention to defaults in libraries and frameworks, because many security failures happen when the application owner assumes the parser is safe out of the box. OWASP API Security Top 10 is a useful companion reference for adjacent authorisation and request-handling risks, and NIST Cybersecurity Framework 2.0 provides a broader control lens for reducing exposure, detecting misuse, and recovering cleanly.
Risk and Threat Considerations
Untrusted XML is a classic case where one parser feature can become an attack primitive. External entity resolution can expose files, metadata, or internal services; entity expansion can turn a small input into a denial-of-service condition. The threat is especially serious when the parser is reachable through public APIs, document upload flows, or integration points that accept third-party content.
Failure mechanism: The attacker supplies XML that either references external resources or recursively expands entities, and the parser follows those instructions before the application can validate or constrain the input.
Impact: External resolution can leak sensitive data or reveal internal network reachability, while expansion can exhaust memory, CPU, or thread pools and disrupt service availability.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Agentic AI Top 10 address the attack and risk surface, while NIST CSF 2.0 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | A1 — Agentic Access Control | XML parser abuse is an input-handling control problem tied to unsafe external access. |
| A2 — Tool and Resource Misuse | External entity resolution abuses a parser as a resource-fetching tool. | |
| A3 — Memory and Context Integrity | Entity expansion weaponises recursive parsing to exhaust resources. | |
| Recommendation — Disable external entity fetching and enforce strict parser boundaries for untrusted XML. Block parser dereferencing of external resources unless explicitly required. Set hard limits on entity recursion, expansion size, and parser resource consumption. | ||
| NIST CSF 2.0 | PR.AC-3 — Remote Access Management | External entity resolution can create unintended network reachability through parsing. |
| PR.DS-1 — Data-at-Rest Protection | External entity resolution can expose local files or sensitive stored content. | |
| DE.CM-1 — Monitoring for Anomalous Events | XML abuse is often visible as abnormal parser errors, fetches, or resource spikes. | |
| Recommendation — Restrict parser network access and allow only approved external references. Prevent parsers from reading arbitrary local files or sensitive data sources. Monitor parser activity for unexpected outbound requests and resource exhaustion patterns. | ||
| CIS Controls v8 | 8.3 — Data Recovery | Entity expansion can trigger service disruption that needs recovery planning. |
| 9.1 — Ensure Only Authorized Data Are Accessible | External entity resolution can expose data outside the intended document boundary. | |
| Recommendation — Test recovery and failover for parsing workloads that may be exhausted by malicious XML. Limit XML parsers to approved input sources and deny arbitrary external dereferencing. | ||
Practitioner Guidance
What to verify: Confirm that the parser profile used in production disables external entity fetching by default and enforces hard limits on entity depth, count, and total expanded size. If different services use different XML libraries, verify each one separately rather than assuming a shared secure baseline.
What good looks like: A malicious XML sample should fail closed, with no outbound fetches, no local file reads, and no meaningful resource spike during parsing. Instrumentation should make parser behaviour visible enough to distinguish a blocked external reference from a legitimate parse error.
Practitioner takeaway: Treat external entity resolution as a trust-boundary and data-exposure problem, and entity expansion as a parser-abuse and availability problem, then harden both because fixing only one leaves a viable XML attack path.
Related resources from NHI Mgmt Group
- How should security teams contain XML external entity risk in document processing pipelines that accept untrusted files?
- What is the difference between prompt injection and token expansion attacks in LLM security?
- What is the difference between role-based access and API key governance for NHI security?
- What is the difference between SAST and DAST for security teams?