---
title: "CWE-776: Improper Restriction of Recursive Entity References in DTDs"
url: https://radicalnotion.ai/cwe/cwe-776
type: cwe
description: "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."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-776: Improper Restriction of Recursive Entity References in DTDs

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** Medium
- **CVEs with this as primary weakness:** 91
- **Of those, in CISA KEV:** 0
- **New in 2026:** 29
- **CWE catalog version:** 4.21

## Description

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.

## 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

| Phase | Note |
| --- | --- |
| Implementation | - |
| Operation | - |

## Applicable platforms

**Languages:** XML (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability | DoS: Resource Consumption (Other) | If the DTD contains a large number of nested or recursive entities, this allows the attacker to expand data exponentially when the DTD is parsed, quickly consuming all system resources. |

## Potential mitigations

### Operation

If possible, prohibit the use of DTDs or use an XML parser that limits the expansion of recursive DTD entities.

### Implementation

Before parsing XML files with associated DTDs, scan for recursive entity declarations and do not continue parsing potentially explosive content.

## Detection methods

### Automated Static Analysis

Automated 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.)

Effectiveness: High

## Demonstrative examples

### Example 1

The DTD and the very brief XML below illustrate what is meant by an XML bomb. The ZERO entity contains one character, the letter A. The choice of entity name ZERO is being used to indicate length equivalent to that exponent on two, that is, the length of ZERO is 2^0. Similarly, ONE refers to ZERO twice, therefore the XML parser will expand ONE to a length of 2, or 2^1. Ultimately, we reach entity THIRTYTWO, which will expand to 2^32 characters in length, or 4 GB, probably consuming far more data than expected.

Attack code:

```xml
<?xml version="1.0"?>
<!DOCTYPE MaliciousDTD [
<!ENTITY ZERO "A">
<!ENTITY ONE "&ZERO;&ZERO;">
<!ENTITY TWO "&ONE;&ONE;">
...
<!ENTITY THIRTYTWO "&THIRTYONE;&THIRTYONE;">
]>
<data>&THIRTYTWO;</data>
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2008-3281 | XEE in XML-parsing library. |
| CVE-2011-3288 | XML bomb / XEE in enterprise communication product. |
| CVE-2011-1755 | "Billion laughs" attack in XMPP server daemon. |
| CVE-2009-1955 | XML bomb in web server module |
| CVE-2003-1564 | Parsing library allows XML bomb |

## Real CVEs with this weakness (sample of 12 of 91)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2019-19144 | - | critical | 9.8 | - | No | 2025-08-01 |
| CVE-2014-2228 | - | critical | 9.8 | - | No | 2020-02-19 |
| CVE-2013-4335 | - | critical | 9.8 | - | No | 2020-02-07 |
| CVE-2026-44020 | Docling: Unsafe XML Entity Expansion in USPTO Patent Backend | critical | 9.4 | - | No | 2026-06-24 |
| CVE-2021-23926 | XMLBeans XML Entity Expansion | critical | 9.1 | - | No | 2021-01-14 |
| CVE-2020-24590 | - | critical | 9.1 | - | No | 2020-08-21 |
| CVE-2026-124078 | plist.js before 5.0.1 Uncontrolled Resource Consumption via Binary Parser | high | 8.7 | - | No | 2026-11-06 |
| CVE-2026-115506 | libexpat through 2.9.0 Denial of Service via Billion Laughs Detection Delay | high | 8.7 | - | No | 2026-10-22 |
| CVE-2026-78681 | NLTK before 3.10.3 Entity Expansion DoS via ElementTree | high | 8.7 | - | No | 2026-08-25 |
| CVE-2026-73569 | fast-xml-parser: Repeated DOCTYPE declarations reset entity expansion limits | high | 8.7 | - | No | 2026-08-13 |
| CVE-2026-3415 | XML External Entity (XXE) Injection via Schema Validation in Multiple WSO2 Products Allows File Reading and Denial of Service | high | 8.7 | - | No | 2026-08-06 |
| CVE-2026-45304 | Symfony: YAML Parser Exponential Memory Allocation via Recursive Collection-Alias Expansion ("Billion Laughs") | high | 8.7 | - | No | 2026-07-14 |

## Related attack patterns (CAPEC)

- [CAPEC-197](https://radicalnotion.ai/capec/capec-197): Exponential Data Expansion

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-405](https://radicalnotion.ai/cwe/cwe-405) | Asymmetric Resource Consumption (Amplification) |
| Parent | [CWE-674](https://radicalnotion.ai/cwe/cwe-674) | Uncontrolled Recursion |
| Related | [CWE-827](https://radicalnotion.ai/cwe/cwe-827) | Improper Control of Document Type Definition |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| WASC | XML Entity Expansion | 44 | - |

## Frequently asked questions

### What is CWE-776?

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.

### What CVEs are caused by CWE-776?

91 recorded CVEs are attributed to CWE-776, including CVE-2019-19144, CVE-2014-2228 and CVE-2013-4335.

### How do you prevent CWE-776?

If possible, prohibit the use of DTDs or use an XML parser that limits the expansion of recursive DTD entities.

### How is CWE-776 detected?

Automated Static Analysis: Automated 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.)

### What are the consequences of CWE-776?

Exploiting CWE-776 can lead to: DoS: Resource Consumption (Other).

### Is CWE-776 actively exploited?

91 recorded CVEs are caused by CWE-776; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/776.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-776). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
