SVG file upload leads to XML injection
The avatar upload accepted SVG files, which are XML-based, and the server rendered them in a way that fetched external resources. An attacker could make the server request internal or external URLs, potentially reading local files or interacting with backend systems.
- Fixed in 4 days
- Disclosed after 4 months
Summary:
Upload Avatar option allows the user to upload image/* . Thus enabling the upload of many file formats including SVG files (MIME type: image/svg+xml) SVG files are XML based graphics files in 2D images. Thus, this opens up an attack vector to upload specially crafted malicious SVG files. The attacks that are possible using SVG files are:
- XSS attack: Stored XSS can be performed by including a "<script>alert(1)</script>" payload inside the XML code of the SVG file can make the browser execute the javascript when the file is rendered. However, only possible when using an <svg> tag to call the file. In this case, <img> tag is used thus not exploitable.
- XXE attack: Injecting malicious XML code inside the SVG file thus executing once the server parses the SVG. [Follow steps to reproduce for this]
- DOS attack: Billion laugh attack is an application-level DOS and can lead to resource exhaustion making the server slow down or crash. I have not tried this but found the below resource about it: https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XXE%20Injection#billion-laugh-attack
Steps to reproduce
-
I observed that when uploading a user avatar picture, the first request was sent to https://api.topcoder.com/v3/members/oldsoul/photoUploadUrl with a POST parameter "contentType" telling the type of file being uploaded. I changed the value to "image/svg+xml".
Now, the response had a preSignedURL variable pointing to the valid S3 object creation URL, and a token variable which gives a random number which is added to the file name which is being uploaded. F781757 -
Second request is a PUT request to https://api.topcoder.com/v3/members/oldsoul/photo with a token variable which is same as the token variable which we received in the first request. Also a variable "contentType" which is used in determining the extension of the file being uploaded. I changed the value to "image/svg+xml" F781767
-
Now, I sent a PUT request to the "preSignedURL" that we got from the first request with HTTP header "Content-Type: image/svg+xml". The body of this request contains the SVG file data to be uploaded. F781788
----------------------------------------------------XXE SSRF------------------------------------------------
- For Fetching External resources from a remote server, upload SVG with <image xlink:href="http://159.65.151.4:81/svg" /> to the SVG file [observed connection to my server when listening via netcat on port 81] => F781770
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="overflow: hidden; position: relative;" width="300" height="200"> <image x="10" y="10" width="276" height="110" xlink:href="http://159.65.151.4:81/svg" stroke-width="1" id="image3204" /> <rect x="0" y="150" height="10" width="300" style="fill: black"/> </svg>
(This is the IP of my personal server. You can include a public resource like http://images.google.com/intl/es_ALL/images/logos/images_logo_lg.gif) => F781773
- For fetching local files from the server itself (LFI),
I created another user named testing68 and uploaded an avatar picture for it. Added the picture link for testing68 user to the XML payload => F781779
<image x="10" y="10" width="276" height="110" xlink:href="/member/profile/testing68-1586481096585.png" stroke-width="1" id="image3204" />Supporting Material/References:
SImilar Reports: https://hackerone.com/reports/97501 https://hackerone.com/reports/142709
Reference material: https://qy.sg/x-ctf-finals-2016-john-slick-web-25/ https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XXE%20Injection#xxe-inside-svg
Thanks
Impact
Exploiting an XXE attack, allows an attacker to interfere with an application's processing of XML data. It often allows an attacker to view files on the application server filesystem, and to interact with any backend or external systems that the application itself can access.
Exploiting the billion laugh DOS attack can mess with the availability of the server and since it is an application level DOS network level filters will not be effective to stop such attack.
Attachments






Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the server parsed user-supplied SVG/XML without disabling external entity and external resource resolution, so links inside the file were fetched.
Impact
An attacker could make the server fetch external or internal resources, potentially viewing files on the server filesystem or interacting with backend systems; a denial-of-service via entity expansion was suggested but not tested.
What the attacker needed
Ability to upload an avatar; server parses SVG/XML with external entities enabled
How it was found
- Request an upload URL with contentType set to image/svg+xml and receive a pre-signed S3 URL and a token.
- Send a PUT request to the photo endpoint with the same token and contentType image/svg+xml.
- Upload the SVG file data to the pre-signed URL with Content-Type image/svg+xml.
- Include an image element with an external link in the SVG and observe a connection to the attacker's server.
- Include a link to another user's avatar path in the SVG to try to fetch a local file.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
An SVG is a picture format that is actually written in XML, a text-based markup language. The upload feature let people upload SVGs, and when the server processed the picture it followed links inside the file, so the attacker could make the server visit a web address of their choosing. This is called XML External Entity (XXE) injection, and it can let an attacker see files on the server or reach systems the server can talk to.
What is XXE?
An XML parser resolves entities the attacker defines, reading local files or making the server send requests.