---
title: "CAPEC-197: Exponential Data Expansion"
url: https://radicalnotion.ai/capec/capec-197
type: capec
description: "An adversary submits data to a target application which contains nested exponential data expansion to produce excessively large output. Many data format languages allow the definition of macro-like structures that can be used to simplify the creation of complex structures. However, this capability can be abused to create excessive demands on a processor's CPU and memory. A small number of nested expansions can result in an exponential growth in demands on memory."
updated: 2026-06-01
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CAPEC-197: Exponential Data Expansion

- **Abstraction:** Detailed
- **Status:** Draft
- **Typical severity:** Medium
- **Likelihood of attack:** High
- **CAPEC catalog version:** 3.9

## Description

An adversary submits data to a target application which contains nested exponential data expansion to produce excessively large output. Many data format languages allow the definition of macro-like structures that can be used to simplify the creation of complex structures. However, this capability can be abused to create excessive demands on a processor's CPU and memory. A small number of nested expansions can result in an exponential growth in demands on memory.

## Alternate terms

- Billion Laughs Attack
- XML Bomb
- XML Entity Expansion (XEE)

## Execution flow

### Step 1: Explore

\[Survey the target\] An adversary determines the input data stream that is being processed by a data parser that supports using subsitituion on the victim's side.

- Use an automated tool to record all instances of URLs to process requests.
- Use a browser to manually explore the website and analyze how the application processes requests.

### Step 2: Experiment

\[Craft malicious payload\] The adversary crafts a malicious message containing nested exponential expansion that completely uses up available server resources. See the "Example Instances" section for details on how to craft this malicious payload.

### Step 3: Exploit

\[Send the message\] Send the malicious crafted message to the target URL.

## Prerequisites

- This type of attack requires that the target must receive input but either fail to provide an upper limit for entity expansion or provide a limit that is so large that it does not preclude significant resource consumption.

## Skills required

- **Low:** Ability to craft nested data expansion messages.

## Resources required

- None: No specialized resources are required to execute this type of attack.

## Consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability | Unreliable Execution, Resource Consumption | Denial of Service |

## Mitigations

- Design: Use libraries and templates that minimize unfiltered input. Use methods that limit entity expansion and throw exceptions on attempted entity expansion.
- Implementation: For XML based data - disable altogether the use of inline DTD schemas when parsing XML objects. If a DTD must be used, normalize, filter and use an allowlist and parse with methods and routines that will detect entity expansion from untrusted sources.

## Example instances

The most common example of this type of attack is the "many laughs" attack (sometimes called the 'billion laughs' attack). For example: \<?xml version="1.0"?\> \<!DOCTYPE lolz \[ \<!ENTITY lol "lol"\> \<!ENTITY lol2 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;"\> \<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;"\> \<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;"\> \<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;"\> \<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;"\> \<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6"\> \<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;"\> \<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;"\> \]\> \<lolz\>&lol9;\</lolz\> This is well formed and valid XML according to the DTD. Each entity increases the number entities by a factor of 10. The line of XML containing lol9; expands out exponentially to a message with 10^9 entities. A small message of a few KBs in size can easily be expanded into a few GB of memory in the parser. By including 3 more entities similar to the lol9 entity in the above code to the DTD, the program could expand out over a TB as there will now be 10^12 entities. Depending on the robustness of the target machine, this can lead to resource depletion, application crash, or even the execution of arbitrary code through a buffer overflow.

This example is similar, but uses YAML. This was used to attack Kubernetes \[REF-686\] a: &a \["lol","lol","lol","lol","lol","lol","lol","lol","lol"\] b: &b \[\*a,\*a,\*a,\*a,\*a,\*a,\*a,\*a,\*a\] c: &c \[\*b,\*b,\*b,\*b,\*b,\*b,\*b,\*b,\*b\] d: &d \[\*c,\*c,\*c,\*c,\*c,\*c,\*c,\*c,\*c\] e: &e \[\*d,\*d,\*d,\*d,\*d,\*d,\*d,\*d,\*d\] f: &f \[\*e,\*e,\*e,\*e,\*e,\*e,\*e,\*e,\*e\] g: &g \[\*f,\*f,\*f,\*f,\*f,\*f,\*f,\*f,\*f\] h: &h \[\*g,\*g,\*g,\*g,\*g,\*g,\*g,\*g,\*g\] i: &i \[\*h,\*h,\*h,\*h,\*h,\*h,\*h,\*h,\*h\]

## Related weaknesses (CWE)

- [CWE-770](https://radicalnotion.ai/cwe/cwe-770): Allocation of Resources Without Limits or Throttling
- [CWE-776](https://radicalnotion.ai/cwe/cwe-776): Improper Restriction of Recursive Entity References in DTDs

## Related attack patterns

| Relationship | CAPEC | Name |
| --- | --- | --- |
| Parent | [CAPEC-230](https://radicalnotion.ai/capec/capec-230) | Serialized Data with Nested Payloads |
| Related | [CAPEC-228](https://radicalnotion.ai/capec/capec-228) | DTD Injection |

## Taxonomy mappings

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

## Frequently asked questions

### What is CAPEC-197?

An adversary submits data to a target application which contains nested exponential data expansion to produce excessively large output. Many data format languages allow the definition of macro-like structures that can be used to simplify the creation of complex structures. However, this capability can be abused to create excessive demands on a processor's CPU and memory. A small number of nested expansions can result in an exponential growth in demands on memory.

### How does a Exponential Data Expansion attack work?

It typically unfolds over 3 phases. It begins with: \[Survey the target\] An adversary determines the input data stream that is being processed by a data parser that supports using subsitituion on the victim's side.

### How do you prevent CAPEC-197?

Design: Use libraries and templates that minimize unfiltered input. Use methods that limit entity expansion and throw exceptions on attempted entity expansion.

### What weaknesses does CAPEC-197 target?

CAPEC-197 exploits 2 CWE weaknesses: CWE-770 (Allocation of Resources Without Limits or Throttling) and CWE-776 (Improper Restriction of Recursive Entity References in DTDs).

### How severe is CAPEC-197?

MITRE rates CAPEC-197 as Medium severity with high likelihood of attack.

Primary source: [MITRE CAPEC](https://capec.mitre.org/data/definitions/197.html)

---

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