An XML external entity vulnerability is a class of attacks that target applications that handle XML input. Extensible Markup Language (XML) is a markup language that defines rules for the encoding of documents. The XML format is both human-readable and machine-readable. XML is defined by standards and specifications such as the World Wide Web Consortium’s (W3C) initial 1.0 specification in 1998 followed subsequently by the 1.1 specification in 2006.
A Document Type Definition (DTD) primarily describes the tree structure of a document and information about the data it contains. DTDs include markup affirmations that define a type of document for the Standard Generalized Markup Language (SGML) family including GML, SGML, HTML, and XML. SGML is a standard for how to specify a document markup language. SGML specifications are themselves a document type definition (DTD). SGML is not in itself a document language, but a description of how one should be specified.
XML is a widely used data format relied upon for web services (SOAP, REST), documents (XML, HTML, DOCX), images and more. Applications must have an XML parser (or perhaps an XML processor)to interpret the XML data. When the XML parser interprets a malicious payload as standard XML data, which can end up accessing or extracting sensitive data on the server.
The attack chain begins when an XML input that contains a reference to an external entity is processed by a poorly configured XML parsing engine. Immediate challenges can include the breach of data, server-side request forgery, denial of service, and more.
Attacks can include the exfiltration and disclosure of locally stored files – the goal of the threat actor is to get passwords, intellectual property, sensitive information. The attack vector through trusted applications further enables the threat actor to use these trusted applications as a pivot point to other targeted systems.
There are many types of XXE attacks to include exploiting:
Ideally, the XML processor must be configured to use DTD that is locally defined. The XML processor should disallow any inline DTD that may be submitted or specified in user XML documents.
There are many XML engines available for different programming languages. Each of these XML engines has a mechanism for disabling inline DTD to, in turn, prevent XXE.
As noted earlier XXE vulnerabilities exist because the application’s XML parsing library supports potentially dangerous XML features. These features are often nor required by the application. If you disable those features you eliminate the possibility of and XXE attack. It is also effective to disable resolution of external entities and also to disable support for XInclude. You can make these via configuration options or by programmatically overriding default behavior.
Hackers aren’t waiting, so why should you? See how Bugcrowd can quickly improve your security posture.