Skip to content
XSS Write-up Intermediate

SVG based Stored XSS

The application allowed uploading an SVG file as a profile picture by bypassing a file-type check that only validated the first request's image header, while the second upload request had no validation. When the original SVG was served without the size parameter, its embedded JavaScript executed, enabling theft of the access token and potential account takeover.

xaonan44 Follow

Published on prashantbhatkal2000.medium.com

Hi, hope you guys doing great! Here is a story about me finding a stored XSS using svg files

Prashant Bhatkal, on prashantbhatkal2000.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 file upload validation was split across two requests, with only the first request's image header checked and the second request accepting any file content, and the uploaded SVG was later served without sanitisation.

Impact

An attacker could steal a victim's access token via a crafted link, potentially leading to account takeover.

What the attacker needed

Ability to upload a profile picture; victim clicks a link to the image

The fix

The application should validate the actual file content on the second upload request and sanitise or disallow SVG uploads, or serve them with a restrictive Content-Type and Content-Security-Policy.

How it was found

  1. Send a valid PNG file in the first upload request to pass the image header check.
  2. In the second upload request, replace the PNG contents with an SVG payload containing JavaScript.
  3. Access the uploaded image URL without the size parameter to load the original SVG and trigger script execution.

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.

The site let users upload a profile picture but only checked the file type in a weak way. An attacker could upload a file that looks like an image but actually contains a script. When someone views the picture, the script runs in their browser and can steal their login token, letting the attacker take over their account.

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.