An internal entity already contains its content inside the XML document, so the parser expands it from local data only. An external entity points to content elsewhere, such as a URL, file, or network resource, and the parser may fetch that data during processing. External entities create the attack surface that XXE abuse depends on.
How internal and external XML entities differ in practice
Internal XML entities are a local convenience: they let the document reuse text that is already defined inside the XML itself. External XML entities are a boundary-crossing feature: they let the parser resolve content from outside the document, which is why they matter for XXE-style abuse. The distinction is not cosmetic, it changes whether parsing stays self-contained or can reach files, URLs, and other resources.
An internal entity is usually about reducing repetition or making XML easier to maintain. An external entity changes the parser’s trust boundary because it introduces retrieval behaviour during parsing. That means the parser can become a fetcher of external content, and the security question shifts from simple syntax handling to whether external resolution is allowed, constrained, or disabled.
For defenders, the important practical difference is that internal entities generally expand to data already present in the document, while external entities can trigger access to resources the application never intended to expose. That is why the same parser feature can be harmless in one configuration and dangerous in another. If you want the parser behaviour and common XXE failure modes explained in more depth, the XXE Guide is the most direct follow-on reference.
Why external entities are the security problem
The risk is not the word “external” by itself, it is the parser’s ability to dereference attacker-influenced content during document processing. Once that is enabled, XML input can be used to read local files, contact internal services, or leak data through error messages and outbound requests. The same mechanism also creates a path for denial of service when expansion or chained lookups consume excessive resources.
Failure mechanism: the parser accepts a document type definition or entity declaration, resolves the external reference, and then substitutes the returned content into the parse flow. If the application does not strictly limit resolution, an attacker can turn ordinary XML handling into file access, server-side request activity, or unintended disclosure.
Impact: confidentiality is the main concern, but integrity and availability can also be affected. A successful XXE condition may expose configuration files, credentials, internal metadata, or service responses, and it can sometimes be used as a stepping stone to broader reconnaissance or pivoting.
What secure XML handling should assume
In secure designs, XML parsers should be treated as unsafe by default until they are explicitly configured otherwise. The safest posture is to disable external entity resolution, block external document type declarations where the parser allows it, and rely on a minimal XML feature set rather than full general-purpose parsing. That reduces the parser’s attack surface without changing the application’s business logic.
Where XML must be processed, the parser should be tested in the same runtime and language version the application actually uses, because safe defaults vary widely. A configuration that looks correct in documentation can still be unsafe if a framework wrapper re-enables entity expansion or if a library upgrade changes parser behaviour.
The most useful linked reference for defensive depth is the Web Application Attacks Guide, which places XXE alongside other parser and input-handling attack patterns that often appear in the same review workflow.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP ASVS, CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V1 — Encoding and Sanitization | XML entity handling is part of input interpretation and parser hardening. |
| V13 — Configuration | Secure parser settings determine whether external entities can be resolved. | |
| V15 — Secure Coding and Architecture | XML processing design must avoid unsafe parsing paths and unintended resource access. | |
| Recommendation — Disable unsafe XML features and validate parser behaviour for attacker-controlled input. Harden XML parser configuration to prevent external entity resolution by default. Design XML handling to minimise parser privileges and external fetch capability. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | XXE is an application-layer input handling flaw requiring secure coding and testing. |
| Recommendation — Test XML parsers and application code for XXE exposure before release. | ||
| NIST SP 800-53 Rev 5 | SI-10 — Information Input Validation | External entities exploit unsafe input interpretation and parser behaviour. |
| Recommendation — Validate XML inputs and constrain parser features that enable unsafe expansion. | ||
Practitioner Guidance
What to verify: confirm whether the application ever processes untrusted XML, whether the parser allows external entity resolution, and whether the deployment can reach local files or internal network endpoints from the parsing context. If any of those are true, treat the parser path as a security-relevant attack surface rather than a purely data-format concern.
Decision rule: if the XML input comes from users, partners, or any upstream system you do not fully control, disable external entity processing unless there is a documented, tested exception with a narrow scope. If the application genuinely needs external references, constrain them to an allowlist and validate the downstream impact of resolution, not just the XML schema.
Common mistake: teams often test only for visible XML parsing success and miss silent outbound fetches, local file reads, or second-order behaviour in libraries and middleware. The right question is not “does the XML parse”, but “what can the parser reach while it parses.”
Practitioner takeaway: internal entities are a local text-reuse feature, but external entities are a trust-boundary decision, so secure XML handling is really about controlling what the parser is allowed to fetch on behalf of the application.
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