Skip to content
XSS Disclosed report Beginner

Stored XSS using SVG

The site served uploaded SVG files with an image/svg+xml content type, so JavaScript embedded in an SVG would execute in the browser. An attacker could upload a malicious SVG that runs script when viewed, stored in user accounts.

abdullah Follow

Originally disclosed on HackerOne

  • Fixed in 5 hours
  • Paid in 5 hours
  • Disclosed after 6 hours

Summary by the program

The way browsers handle SVG files is terrible. If you're serving SVG files that your users can upload, only allow them to be served as text/plain.

The report

Hi ,

Background

I had problem in setup the airship at ubuntu so I tested on your site .
If you uploads any file thet can use for XSS (HTML,SWF,etc) the content type will change to "text/plain; charset=us-ascii" . But for images it will stay the same . so if you upload SVG with JS content it will work fine !

The "Content-Type: image/svg+xml; charset=us-ascii" header will make this attack works .

Just upload the svg file to the site .

PoC

123123.png
123123.png From the original on HackerOne

SVG's is not good sometimes to view as image and it will be stored in users accounts.

Thanks

The original report as published on HackerOne, by abdullah. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 upload handler preserved the image/svg+xml content type for SVG files instead of forcing a safe type like text/plain, allowing script inside the SVG to execute.

Impact

An attacker could run script in the context of the site when a victim views the uploaded SVG, and the file is stored in user accounts.

What the attacker needed

Ability to upload files; victim views the uploaded SVG

The fix

SVG files uploaded by users should be served as text/plain so the browser does not execute any embedded script.

How it was found

  1. Upload an SVG file containing JavaScript to the site.
  2. The server stores it and serves it with an image/svg+xml content type.
  3. When the SVG is viewed, the embedded script runs in the browser.

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.

When you upload a picture to a website, the site tells the browser what kind of file it is. SVG is a picture format that can also contain code. If the site labels an uploaded SVG as a picture, the browser may run that code, letting an attacker do things in your account.

What is XSS?

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

More by abdullah

View all

5 more disclosed reports, best first.

More from Paragon Initiative Enterprises

View all

The newest disclosed reports for this program.

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.