An XML External Entity vulnerability is used to attack a program that uses XML files from an external source. If executed properly, an attack can let you view the contents of files on a host system. The way this is done is using entity’s in XML which essentially act as variables.
For example:
<?xml version=”1.0″ ?>
<!DOCTYPE student [
<!ELEMENTstudent ANY>
<!ENTITY student “Daniel Mahoney”>
]>
<student>&student;</student>
In the above code any use of the entity student will be replaced with “Daniel Mahoney” when the XML is parsed.
<?xml version=”1.0″ ?>
<!DOCTYPE passwd [
<!ELEMENT passwd ANY>
<!ENTITY passwd SYSTEM “file:///etc/passwd”>
]>
<passwd>&passwd;</passwd>
Adding SYSTEM to the entity now allows you to print out the contents of a file on the host system. This can be used to get sensitive information and, if the file being read provides infinite output, can be used for Denial of Service attacks.
The best way to protect yourself from these attacks is to turn off external entity parsing in the config of whatever software you have.
From the blog CS@Worcester – Site Title by volk676 and used with permission of the author. All other rights reserved by the author.