DTD processing is the part of XML parsing that interprets document type declarations and related entity rules. It is often unnecessary in modern applications and becomes risky when left enabled for untrusted XML, because it can support entity expansion attacks and help external entity abuse.
What DTD Processing Does
DTD processing is the XML parser behavior that reads document type declarations, resolves entity rules, and applies document structure rules before content is fully parsed. It is a legacy XML feature, but one that still matters because parser behavior can change the security profile of an application.
In practice, DTD support can expand what an XML document is allowed to reference and substitute. That makes it useful for older document workflows, but it also means the parser may do more than simply read tags and elements, which is why many modern systems disable it by default for untrusted input.
How DTD Processing Affects XML Parsing
A DTD can define element declarations, attribute defaults, entities, and validation rules. When a parser processes it, the XML document is interpreted together with those extra instructions, so the final parsed result may differ from the raw text that was submitted.
This is why DTD handling is not just a formatting detail. It influences how the parser resolves references, whether internal entities are expanded, and whether the document is treated as conforming to a declared structure. In secure applications, those behaviors can be valuable only when the source is trusted and the parser configuration is tightly controlled.
For a deeper view of XML parser behavior and hardening choices, the broader XML security controls in NIST SP 800-53 Rev 5 Security and Privacy Controls are often the right reference point for access, integrity, and configuration expectations.
Why DTD Processing Is Often Disabled
Many modern applications do not need DTD processing at all, and disabling it reduces parser complexity and exposure. If the parser accepts untrusted XML, DTD support can create unintended behavior such as entity expansion, local file access through external entities, or other parser-side side effects that the application never intended to allow.
This is why XML hardening guidance usually treats DTD support as unnecessary unless there is a clear functional requirement. The safest default is to reject or ignore DTDs for untrusted sources, especially in integrations, APIs, and document upload paths where the XML origin cannot be fully trusted.
Related XML security controls are also reflected in OWASP API Security Top 10 when XML is accepted through API-facing services, because parser abuse can become an API input-handling problem rather than a purely formatting issue.
Common Failure Modes and Safe Parsing Expectations
The most important failure mode is allowing DTD-enabled parsing on data that should be treated as untrusted. Once that happens, the parser may resolve references, expand entities, or interpret document structure in ways that can exhaust resources or expose unintended information.
Safe XML processing usually means using the least permissive parser settings, rejecting external entity resolution, and allowing DTDs only when the business need is explicit and the source is trusted. In environments that handle sensitive data or regulated content, the expected outcome is predictable parsing, not flexible document interpretation.
Where XML input is part of a managed service or compliance-sensitive workflow, security and trust expectations are commonly reinforced by SOC 2 Trust Services Criteria (AICPA) and EU General Data Protection Regulation (GDPR) when personal data could be exposed through parser misuse.
Risk and Threat Considerations
DTD processing becomes risky when untrusted XML can influence how a parser resolves entities or interprets external references. That can enable entity expansion attacks, file disclosure, denial of service, or other parser abuse that turns a simple input feature into an attack path.
Failure mechanism: The parser accepts a document type declaration and follows entity or external reference rules that the application did not intend to trust, which can change parsing behavior before the application has a chance to validate the input.
Impact: Attackers can trigger excessive resource consumption, retrieve unintended data, or cause the application to process content in a way that bypasses normal input expectations.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP API Security Top 10 addresses the attack surface, NIST SP 800-53 Rev 5 sets the technical controls, and SOC 2 (AICPA) and GDPR define the regulatory obligations.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | SI-10 — Information Input Validation | DTD processing changes how XML input is interpreted before validation. |
| Recommendation — Disable risky XML features and validate untrusted XML input before parsing it further. | ||
| OWASP API Security Top 10 | API8 — Security Misconfiguration | DTD-enabled XML parsing is a parser configuration issue that can expose API input surfaces. |
| Recommendation — Harden XML parser settings and reject DTDs for untrusted API input. | ||
| SOC 2 (AICPA) | CC6.1 — Logical Access Security Software | Unsafe XML parsing can weaken logical controls around how input is processed and trusted. |
| Recommendation — Configure application controls to prevent unsafe parser behavior on untrusted XML. | ||
| GDPR | Article 32 — Security of processing | DTD abuse can expose personal data through unsafe XML processing. |
| Recommendation — Apply secure parsing settings where XML processing could affect personal data protection. | ||
Related resources from NHI Mgmt Group
- What breaks when SAML signature verification and assertion processing are separated?
- How can organisations reduce risk from AI agents processing hidden instructions?
- How should security teams enforce segregation of duties in payroll processing?
- How do organisations reduce blast radius if protobuf processing is compromised?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on September 29, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org