Skip to content
XSS Write-up Beginner

SVG Injection: When a Profile Picture Upload Becomes a JavaScript Execution Vector

A profile picture upload feature that claimed to accept only JPG and GIF files actually accepted an SVG file containing JavaScript. Because the uploaded file was stored and later served back, the script ran when the profile picture was viewed, letting the author steal cookies and JWT tokens from anyone who opened the link.

Deepanshu Follow

Published on medium.com

Hi, I’m Deepanshu Ladwal, a security researcher and bug hunter, Let’s get straight to the interesting part. while Doing internal Testing on a a company i counter a feature upload profile picture where we have permission to upload only JPG,GIF,JPG file .

Deepanshu, 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 server trusted the file extension or client-side checks instead of validating the uploaded file's real type and content, and then served the stored file in a way that let embedded script run.

Impact

The author states they could steal cookies and JWT tokens from anyone who opened the link, and claims the severity is high for that reason, though the write-up gives no further detail on how the tokens were used.

What the attacker needed

Upload feature on a profile picture; victim views the uploaded image

How it was found

  1. Try uploading an SVG file to the profile picture feature that claims to accept only JPG and GIF.
  2. Observe that the server accepts the SVG file.
  3. Embed JavaScript inside the SVG file and upload it; it is stored in an S3 bucket.
  4. Open the profile picture and see the JavaScript execute.

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.

A website let people upload a profile picture but said only image types like JPG and GIF were allowed. The server did not actually check the file type, so the author uploaded a different kind of image file (SVG) that can carry a small script. When the picture was displayed, the browser ran that script, which could read the viewer's login data.

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.