Exploiting XXE via image file upload

after mapping the website we find a file upload in the post comment functionnality

this application allows users to upload images, and process or validate these on the server after they are uploaded. Even if the application expects to receive a format like PNG or JPEG, the image processing library that is being used might support SVG images. Since the SVG format uses XML, we can submit a malicious SVG image and so reach hidden attack surface for XXE vulnerabilities.

let's create an svg image that contains XML payload to retrieve the /etc/hostname file from the application's server

<?xml version="1.0" standalone="yes"?><!DOCTYPE test [ <!ENTITY xxe SYSTEM "file:///etc/hostname" > ]><svg width="128px" height="128px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"><text font-size="16" x="0" y="16">&xxe;</text></svg>

now let's upload this file

after clicking on post comment

click on back to blog to see the svg image we have uploaded in the comment section

right click on this svg image and click on open in new tab

submit the server hostname data and we have solved the lab

hope you found this walkthrough easy to understand and follow

Greeting From Sayonara

Last updated

Was this helpful?