Skip to content
XSS Write-up Beginner

SVG Image to Stored XSS

A chat feature allowed uploading SVG files that were served and rendered as HTML, so an attacker could embed JavaScript in an SVG and have it execute in the context of the site when another user opened the file. The author demonstrated an alert and then a cookie-reading payload, though the report was closed as a duplicate.

medium.com

Published on medium.com

While testing the program, I found that there was a chat function. I inspected it and discovered that I could upload any file.

Raccoon, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the chat upload accepted SVG files and served them with a content type or context that let the browser execute embedded script rather than treating the file as an inert image.

Impact

An attacker could run script in another chat user's browser when that user opened the uploaded SVG, which could be used to read cookies or act as the victim, though the report was marked duplicate.

What the attacker needed

Access to the chat upload feature; victim opens the uploaded SVG

How it was found

  1. Find the chat function and note that it accepts file uploads.
  2. Create an SVG file containing a script that shows an alert.
  3. Upload the SVG file to the chat.
  4. Open the uploaded file from another user's view in the chat and observe the script running.
  5. Replace the payload with one that reads the user cookie and upload it again to confirm.

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 write-up has not been written yet. The Original tab links to the source.

An SVG is an image format that can also contain scripts. If a website lets people upload SVGs and then shows them in a way that runs those scripts, an attacker can make another user's browser run code on the site. That is called stored cross-site scripting, because the malicious file is stored on the server and runs when someone views it.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.