CAPEC Details
Name XML Entity Expansion
Likelyhood of attack Typical severity
High Medium
Summary An attacker submits an XML document to a target application where the XML document uses nested entity expansion to produce an excessively large output XML. XML allows 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.
Prerequisites This type of attack requires that the target must receive XML 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.
Execution Flow
Step Phase Description Techniques
1 Explore [Survey the target] Using a browser or an automated tool, an attacker records all instances of web services to process XML requests.
  • Use an automated tool to record all instances of URLs to process XML requests.
  • Use a browser to manually explore the website and analyze how the application processes XML requests.
2 Exploit [Launch an XML Entity Expansion attack] The attacker crafts malicious XML message to force recursive entity expansion (or other repeated processing) that completely uses up available server resource.
  • Send the malicious crafted XML message containing recursive entity uses to the target URL.
Solutions Design: Use libraries and templates that minimize unfiltered input. Use methods that limit entity expansion and throw exceptions on attempted entity expansion. Implementation: Disable altogether the use of inline DTD schemas in your XML parsing objects. If must use DTD, normalize, filter, use an allowlist and parse with methods and routines that will detect entity expansion from untrusted sources.
Related Weaknesses
CWE ID Description
CWE-400 Uncontrolled Resource Consumption
CWE-770 Allocation of Resources Without Limits or Throttling
Related CAPECS
CAPEC ID Description
CAPEC-230 Applications often need to transform data in and out of the XML format by using an XML parser. It may be possible for an adversary to inject data that may have an adverse effect on the XML parser when it is being processed. By nesting XML data and causing this data to be continuously self-referential, an adversary can cause the XML parser to consume more resources while processing, causing excessive memory consumption and CPU utilization. An adversary's goal is to leverage parser failure to their advantage. In most cases this type of an attack will result in a XML Denial of Service (XDoS) due to an application becoming unstable, freezing, or crashing. However it may be possible to cause a crash resulting in arbitrary code execution, leading to a jump from the data plane to the control plane [REF-89]. XDoS is most closely associated with web services, SOAP, and Rest, because remote service requesters can post malicious XML payloads to the service provider designed to exhaust the service provider's memory, CPU, and/or disk space. The main weakness in XDoS is that the service provider generally must inspect, parse, and validate the XML messages to determine routing, workflow, security considerations, and so on. It is exactly these inspection, parsing, and validation routines that XDoS targets. This attack exploits the loosely coupled nature of web services, where the service provider has little to no control over the service requester and any messages the service requester sends.
Taxonomy: WASC
Entry ID Entry Name
44 XML Entity Expansion