pentesting, updated
Testing for XML Injection
Check whether user input is inserted into XML unsanitized, letting you inject extra elements/attributes or break the document structure.
Goal
Confirm input reaching XML is escaped for the XML context, not concatenated raw.
How to test
Inject structural XML characters into a field that ends up in an XML document or SOAP body:
curl -s https://example.com/api -H "Content-Type: application/xml" \
--data '<user><name>test</name><role>user</role></user>'
# then try injecting a closing tag + new element:
curl -s https://example.com/api -H "Content-Type: application/xml" \
--data '<user><name>test</name><role>user</role><role>admin</role></user>'
What to look for
An extra element accepted and acted on (e.g. a duplicated/overriding <role>), or a parser error leaking structure.
Notes
Closely related to XXE / XML External Entity attacks — once you control XML structure, test entity expansion too.
References
- OWASP WSTG-INPV-07 — Testing for XML Injection.