XXE Attacks
What is XML
XML => Extensible markup language
Basically used for
storing
andtransporting
data btw theapplication
and theserver
.Like HTML, XML also uses tree like structures of
tags
anddata
, but XML does not use predefined tags.
What are XML entities
XML entities are a way of representing an item of data
within an XML document, instead of using the data itself.
For example : <
and >
are <
and >
respectively in XML format.
What is a DTD
Document Type Definition contains the declarations that can define the structure of an XML document.
The DTD is declared within the
DOCTYPE
element at the start of the XML document.
XML allows custom entities to be defined within the DTD, For example :
This means that any usage of the myentity
in the XML format, is replaced by my enitity value
.
External Entities
XML external entities are a type of custom entity
whose definition is located outside
the DTD where they are declared.
The declaration uses a keyword called SYSTEM
, and must specify a URL from which the value of the entity should be loaded.
We can even use the file://
protocol, so that the external entities can load them from a file.
Now what is an XXE Injection
XXE => XML external entity injection
It is a web security vulnerability that allows an attacker to interfere with an application's processing of
XML data
.It often allows an attacker to view files on the application server filesystem, and to interact with the back-end.
Sometimes an attacker
can chain both, the XXE attack and a SSRF to get hold of the backend server.
How do they arise
Some applications use the
XML format
to exchange data between thebrowser
and theserver
.So the application always uses a standard library or an API to process the XML data
on the server
.
XXE arises because the XML format contains various dangerous features and standard parsers
to interpret the format, EVEN THO THEY ARE NOT USED BY THE APPLICATION.
Note
XML external entities are the custom entites whose values are loaded outside from the DTD.
Which means they can be vulnerable from a security perspective, because they allow something to load
outside
theDTD
or load the contents of a file based on thepath
.
Types of XXE Attacks
Exploiting XXE to retrieve files
Where an external entity is defined conatining the contents of the file and retuned in the application response
Exploiting XXE to perform SSRF attacks
Where an external entity is defined based on a URL to a backend system
Exploiting Blind XXE to exfiltrate data
An out-of-band approach, where sensitive data is transmitted from the application server to a system that the attacker controls
Exploiting Blind XXE to retrieve data via error messages
Where the attacker can trigger a parsing error message containing sensitive data
Last updated