XXE
XMl External Entity is a type of injection where attacker can exploit the processing of XML data by including malicious external entities, which can lead to RCE,DOS, or disclouser of internal files, this happens due to poor validation, .NET has this vuln.
DTD
- document type definition ⇒ defines a strucutre,legal elements,and attributes for XML documents.
- To know that the application uses XML you will find the tag (Content type) as:
- content type: text/plain;charset=UTF-8 || application/xml
- after that you check for the tag which may be vulnerable as it may has a dynamic reaction with the server
CDATA
- Suppose that the server does not support xml, then we use CDATA to enforce the server to accept the special chars of xml like < and >
- Example:
- suppose the code passed from the frontend but can`t pass from the backend, then we use the CDATA like:
- in the last example the web server may prevent inline entities, then we must use external DTD file with XML reference, but we must but % before every variable if we use external entity.
- Solve issue in last example
- the content of the filr xxe.dtd is ⇒ <!ENTITY joined “&begin;&file;&end;”>
Exploitation
- suppose the vlun tag is <email>
- just object the entity and call it
- <!DOCTYPE email [ <!ENTITY company “HI”> ]>
- use company entity:
- <email> &company; </email>
Get Mohammed Hassan’s stories in your inbox
Join Medium for free to get updates from this writer.
Example:
- The vuln one:
- After Exploitation
- HI must be reflected
- once HI is reflected , then ask it to give you sensetive data like /etc/passwd, but dont forget to add SYSTEM.
- it will be like:
Tips And Tricks
- when the app is using json , convert it to xml then check for XXE
- when you convert the json to xml do not forget to change the content type
- website to convert form json to xml ⇒JSON To XML Converter
- if a website enables you to upload svg then inject XXE in the photo like:
- if the firewall do not allow you to read files like /etc/passwd then:









