CAPEC-491: Quadratic Data Expansion
Also known as: XML Entity Expansion (XEE)
An adversary exploits macro-like substitution to cause a denial of service situation due to excessive memory being allocated to fully expand the data. The result of this denial of service could cause the application to freeze or crash. This involves defining a very large entity and using it multiple times in a single entity substitution. CAPEC-197 is a similar attack pattern, but it is easier to discover and defend against. This attack pattern does not perform multi-level substitution and therefore does not obviously appear to consume extensive resources.
Last updated
Overview
CAPEC-491 (Quadratic Data Expansion) is a detailed-level attack pattern catalogued by MITRE in the Common Attack Pattern Enumeration and Classification (CAPEC). It describes a recurring method attackers use to exploit software weaknesses.
How the attack works
The phases an attacker typically follows to carry out this attack.
- Step 1Explore
[Survey the target] An adversary determines the input data stream that is being processed by a data parser that supports using substituion 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 2Exploit
[Craft malicious payload] The adversary crafts malicious message containing nested quadratic expansion that completely uses up available server resource.
- Step 3Exploit
[Send the message] Send the malicious crafted message to the target URL.
What the attacker needs
Prerequisites
- This type of attack requires a server that accepts serialization data which supports substitution and parses the data.
Consequences
What a successful CAPEC-491 attack can achieve.
Unreliable Execution, Resource Consumption
Affects: Availability
Denial of Service
How to mitigate it
Defenses that reduce the risk of CAPEC-491.
- 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.
Examples
In this example the attacker defines one large entity and refers to it many times. ]> &x;&x; ... [100K of them]... &x;&x; This results in a relatively small message of 100KBs that will expand to a message in the GB range.
Terminology & mappings
Alternate terms
- XML Entity Expansion (XEE)
Frequently asked questions
Common questions about CAPEC-491.
- What is CAPEC-491?
- An adversary exploits macro-like substitution to cause a denial of service situation due to excessive memory being allocated to fully expand the data. The result of this denial of service could cause the application to freeze or crash. This involves defining a very large entity and using it multiple times in a single entity substitution. CAPEC-197 is a similar attack pattern, but it is easier to discover and defend against. This attack pattern does not perform multi-level substitution and therefore does not obviously appear to consume extensive resources.
- How does a Quadratic 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 substituion on the victim's side.
- How do you prevent CAPEC-491?
- 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-491 target?
- CAPEC-491 exploits 1 CWE weakness, including CWE-770 (Allocation of Resources Without Limits or Throttling).
References
Attack-pattern data is sourced from the MITRE CAPEC catalog (v3.9). Weakness associations link to the corresponding CWE entries on RadicalNotion.AI.
Defend against CAPEC-491
Track the CVEs and weaknesses attackers exploit with this technique, with AI-written analysis and remediation guidance.