The previous articles in this series have touched upon in-band XML External Entity (XXE), that is when an attacker can send a request with an XXE payload and get a response back from the web application containing some data. However, this is often not the case.
There are many situations whereby an attacker can send an XML External Entity (XXE) payload to a web application, but the response will never be returned back. This is known as an Out-of-band vulnerability. The process for exploiting such a vulnerability is similar to the above example using parameter entities, with one difference – the attacker needs to get the XML parser to make an additional request to an attacker-controlled server in order to read the contents of the file.
The following is an example of how an attacker could leverage parameter entities to steal data using an Out-of-band (OOB) technique.
|Request||Attacker DTD (attacker.com/evil.dtd)|
The XML parser will first process the
%file parameter entity, which loads the file
/etc/lsb-release. Next, the XML parser will make a request to the attacker’s DTD at http://attacker.com/evil.dtd.
Once the attacker’s DTD is processed, the
all% parameter entity will create a general entity called &send;, which contains a URL containing the file’s contents (e.g. http://attacker.com/?collect=DISTRIB_ID=Ubuntu…). Finally, once the URL is constructed, the
&send; entity is processed by the parser, which makes a request to the attacker’s server. The attacker can then log the request on their end and reconstruct the contents of the file from the logged request.
XML External Entity (XXE), while not as prevalent as other vulnerabilities, is a very serious vulnerability that affects almost any web application that in some way or other parses XML.
XML External Entity (XXE) can be used to steal system files and source code on local servers, as well as launch Server-side Request Forgery (SSRF) attacks to other servers on the internal network. What’s more XXE can also be used to cause Denial of Service when using some XML parsers, and external entities are enabled by default even though they are almost never needed by the application.
Out-of-band XML External Entity (OOB-XXE)