Sitemap
Mohammed Hassan

Mohammed Hassan

Cyber Security Engineer, interested in Penetration Testing

XXE

3 min readAug 27, 2025

--

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.

Press enter or click to view image in full size

DTD

  • document type definition ⇒ defines a strucutre,legal elements,and attributes for XML documents.
Extensible Markup Language
DTD (Document Type Definition)
  • 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:
Press enter or click to view image in full size
  • suppose the code passed from the frontend but can`t pass from the backend, then we use the CDATA like:
Press enter or click to view image in full size
  • 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
Press enter or click to view image in full size
  • 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:
Press enter or click to view image in full size
  • After Exploitation
Press enter or click to view image in full size
  • 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:
Press enter or click to view image in full size

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:
Press enter or click to view image in full size
  • if the firewall do not allow you to read files like /etc/passwd then:
Press enter or click to view image in full size

--

--

Mohammed Hassan
Mohammed Hassan

Cyber Security Engineer, interested in Penetration Testing