INFORMATION DISCLOSURE

External XML Entities uses the "SYSTEM" and "PUBLIC" keyword with the external reference path after it such as "file:///path/path"

READING SENSITIVE FILES: /ETC/PASSWD

#once the internal XML entities are validated - use external file entities keyword to test for local file disclosure
#find web pages that accept an XML user input
root@oco:~$ burpsuite
root@oco:~$ BROWSER > FoxyProxy > Burp
root@oco:~$ BURP SUITE > Proxy > Intercept is on
root@oco:~$ BROWSER > {targetSite:port}
 input field: 127.0.0.1
 ...
 * submit the expected user input
 
BURP > Proxy > Intercept > Raw
 Request
  ...
  POST /submitDetails.php HTTP/1.1
   <?xml version="1.0" encoding="UTF-8"?>
    <root>
     <name>First</name>
     <tel></tel>
     <email>[email protected]</email>
     <message>This is a test email</message>
    </root>

 * forms that appears to be sending user input data in an XML format can be tested for potential XXE vulnerability
    - the target page may be vulnerable to XXE injection if the user input isn't properly sanitized or safely parsed

#identify which elements are being displayed IOT know which elements to injext malicious xml input
#if no elements are displayed, utilize blind xxe injection method
BURP > Repeater
 Request
  ...
   <?xml version="1.0" encoding="UTF-8"?>
    <root>
     <name>First</name>
     <tel></tel>
     <email>[email protected]</email>
     <message>This is a test email</message>
    </root>
 Response
  ...
  HTTP/1.1 200 OK
   check your email [email protected] for verification...
  
 * the email field is reflected in the response and may be vulnerable to xxe injection

READING SENSITIVE FILES: ~/.SSH/ID_RSA

READING SENSITIVE FILES: DIRECTORY LISTING

READING SOURCE CODE

the ability to obtain the webapp source code would allow the attacker to perform a Whitebox penetration test to unveil more vulnerabilities in the webapp or reveal secret configurations such as DB passwords or API keys. when reading source code, everything must conform to the XML format else no output will be displayed. characters that breaks the XML format are "</>/&". additionally, binary data can't be read as it doesn't conform to the XML format. IOT read source code data that contains characters that may break XML format, use a PHP wrapper filter to encode the PHP source file.

PHP wrapper filters are used to encode PHP source files, such that they would not break the XML format when referenced

READING SOURCE CODE: ADVANCED FILE DISCLOSURE

another method to extract any kind of data to include binary data that does not conform to the XML format for any web application backend is to wrap the content of the external file reference with a CDATA tag <![CDATA[ FILE_CONTENT ]]>. when this is used, the XML parser would consider this part raw data, which may contain any type of data, including any special characters.

READING SOURCE CODE: ERROR-BASED XXE

this method can be used to read any type of file including source files; however, it is not as realible as the Advanced File Disclosure method. to do so, simply change the file name in the DTD script to point to the file to be read e.g., file:///var/www/html/submitDetails.php

Last updated