I want to bring to the attention of this forum a class of vulnerabilities affecting XML parsers deployed in web services endpoints. We have identified several attack vectors that can be used to cause denial of service or information disclosure in SOAP processing engines.
1. XML Entity Expansion (Billion Laughs Attack)
By crafting a SOAP request with recursive entity definitions, an attacker can force the XML parser to expand entities exponentially, consuming all available memory on the server. The following payload demonstrates the technique:
<?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;">
]>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<data>&lol4;</data>
</soap:Body>
</soap:Envelope>
This is particularly dangerous because the SOAP request appears small on the wire but expands to gigabytes in memory. Most XML parsers process the DTD before the application layer has any opportunity to reject the message.
2. BEA WebLogic Server XML Parser Denial of Service (CVE-2002-2344)
BEA WebLogic Server 7.0 and 7.0.0.1 are vulnerable to a denial of service attack through malformed XML submitted to the web services endpoint. The XML parser in WebLogic does not enforce limits on entity expansion depth or total expansion size. A specially crafted SOAP request can exhaust server memory and cause the JVM to become unresponsive.
BEA has acknowledged the issue. Administrators should apply the patch referenced in BEA Security Advisory BEA03-28 and configure entity expansion limits in the weblogic-xml-parser configuration. As a temporary workaround, consider deploying an XML firewall or validating proxy in front of the WebLogic SOAP endpoint.
3. XPath Injection in SOAP Dispatchers
Several SOAP frameworks use XPath expressions constructed from request data to route messages to the appropriate handler. If user-supplied data is concatenated into XPath expressions without sanitization, an attacker can inject arbitrary XPath that extracts data from the SOAP message or server configuration.
I recommend that all XWSS members review their web services deployments for these issues. I will post additional details and mitigation strategies in follow-up messages.
- Mark Hendricks