Skip to content
XSS Write-up Beginner

How an Unsanitized SVG Upload Led to Cross-Site Scripting (XSS) a

A collaboration platform accepted SVG logo uploads and served them inline from the main application domain without a restrictive CSP, so embedded JavaScript ran in the application's origin. An attacker could upload a crafted SVG and, if a team member opened the file URL, execute script in that user's session context.

T4nv1 Follow

Published on medium.com

When testing user profile customization settings, file upload fields are often a primary focus for security researchers. While developers typically restrict file extensions to common image formats like JPEG or PNG, SVG (Scalable Vector Graphics) files are frequently overlooked.

T4nv1, 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 application accepted SVG uploads and served them inline from the main application origin with the SVG content type and no enforcing CSP, so embedded script executed in the site's context.

Impact

If an administrator or team member opened the uploaded logo link, the script could run with access to that user's session state and page content, though it required the victim to visit the file URL.

What the attacker needed

Ability to upload a workspace logo; victim opens the uploaded file URL

The fix

The team moved uploaded assets to an isolated cookie-less domain, sanitised SVG XML to strip scripts and event handlers, and added a restrictive CSP on raw asset delivery.

How it was found

  1. Upload a normal SVG logo through the workspace logo upload endpoint and note the returned file URL.
  2. Upload a test SVG containing a script block and observe that the server accepts it without stripping the tags.
  3. Request the stored file and inspect the response headers, finding inline SVG content type and no CSP.
  4. Open the file URL and see the embedded script execute in the application domain.

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 lets people upload a picture to use as a logo. Some picture formats, like SVG, can secretly contain small programs. Because the site stored the picture on its own main address and showed it directly in the browser, that hidden program ran as if it were part of the site itself, which could let an attacker act as the logged-in user who opened it.

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 T4nv1

View all

113 more disclosed reports, best first.

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.