CWE-776: Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion')

What is CWE-776?

CWE-776 is Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion'). The flaw arises when The product uses XML documents and allows their structure to be defined with a Document Type Definition (DTD), but it does not properly control the number of recursive definitions of entities.

OWASP TOP 10:2025 RANK2 — A02:2025 — Security Misconfiguration
Related CVES (365 days)-
AbstractionBase
Likelihood of exploitMedium

No data

No vulnerability data for CWE-776

No data

No vulnerability data in CISA KEV for CWE-776

Official definition

ByMitre CWE

The product uses XML documents and allows their structure to be defined with a Document Type Definition (DTD), but it does not properly control the number of recursive definitions of entities.

If the DTD contains a large number of nested or recursive entities, this can lead to explosive growth of data when parsed, causing a denial of service.

Characteristics

Alternate terms

  • XEE — XEE is the acronym commonly used for XML Entity Expansion.
  • Billion Laughs Attack
  • XML Bomb — While the "XML Bomb" term was used in the early years of knowledge of this issue, the XEE term seems to be more commonly used.

Modes of introduction

  • Implementation
  • Operation

Common consequences

ImpactScopeExplanation
DoS: Resource Consumption (Other)AvailabilityIf parsed, recursive entity references allow the attacker to expand data exponentially, quickly consuming all system resources.

Risk mitigations

  1. OperationIf possible, prohibit the use of DTDs or use an XML parser that limits the expansion of recursive DTD entities.
  2. ImplementationBefore parsing XML files with associated DTDs, scan for recursive entity declarations and do not continue parsing potentially explosive content.

Detection methods

MethodApproachEffectiveness
Automated Static AnalysisAutomated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)High

Representative vulnerabilities

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.