An application has an "import from XML" feature. Someone uploads a file, the server parses it and shows the result. If the parser is on default settings, that feature may be vulnerable to XML External Entity injection.
The mechanism
XML lets a document declare entities in a DOCTYPE. Some entities point outward, to a file or a URL. If the parser resolves them and the application returns parsed content, whatever the entity pointed at ends up in the response.
A safe way to test it
Run this only against a lab or a system you are authorised to test. The document declares an entity for a harmless local file and references it in a field the page echoes back:
<?xml version="1.0"?> <!DOCTYPE item [ <!ENTITY probe SYSTEM "file:///etc/hostname"> ]> <item><name>&probe;</name></item> If the hostname appears where the name should be, the parser resolved the external entity. That is the finding. No need to read anything more sensitive to prove it.
Why filtering fails
The first defensive instinct is to reject uploads containing ENTITY or SYSTEM. XML can be encoded in different ways, and string checks tend to miss some of them. The check also sits in the wrong place: the dangerous behaviour belongs to the parser.
The fix
Disable DTD processing. In Python, use defusedxml rather than the standard library parsers for untrusted input. In Java, set the http://apache.org/xml/features/disallow-doctype-decl feature to true on the factory. Where DTDs are genuinely needed, disable external entity resolution and test again.
After the change, send the same document. The response should be a parse error, not a hostname.
Where it hides besides an obvious XML form
Many features parse XML without saying so. An SVG image upload is XML. A DOCX or XLSX file is a zip archive of XML parts, so an "import spreadsheet" button can reach an XML parser. SOAP endpoints take XML by design. And some APIs accept XML if you change the Content-Type header from JSON, even though the front end never sends it. When you review an application, list every place it accepts a file or a body, and ask which of them ends up in an XML parser.
When nothing comes back
Not every vulnerable parser echoes content. If the response never shows parsed fields, the entity may still be resolved. Those cases are called blind XXE, and testers confirm them by watching for an outbound request from the server to a host they control. That is a topic for a lab with the right setup, and it is one more reason the fix belongs in the parser: you do not have to know which features echo and which do not.
Practise both sides
The free XXE XML import lab on Codelivly lets you run the test and then confirm the fix. When you want the surrounding workflow, from recon to writing the finding, the Web Application Hacking book on Codelivly Resources continues from here.


