Exploiting XXE via image file upload
Description
This lab lets users attach avatars to comments and uses the Apache Batik library to process avatar image files.
To solve the lab, upload an image that displays the contents of the /etc/hostname
file after processing. Then use the "Submit solution" button to submit the value of the server hostname.
Approach
Upon accessing the lab, I headed straight to the comments section where I stumbled upon an image file upload functionality, which I immediately recognized as a potential avenue for exploiting XXE. To execute XXE exploitation, I needed to inject XML into the system, and SVG (Scalable Vector Graphics) files, being XML-based, presented an ideal choice. So, I crafted a sample SVG file with XML syntax like the following:
Then, I injected my payload into it:
Combining the two, the full payload looked something like this:
I saved this payload in a text file and uploaded it. Subsequently, upon navigating to my comment and opening the avatar, I observed the hostname appearing there. By submitting that value, I successfully solved the lab.