Skip to content
XSS Write-up Intermediate

Stored XSS via SVG File Upload Leading to Account Takeover in an LMS Platform

The application allowed users to upload SVG profile pictures without sanitisation and served them from the same origin, so JavaScript inside the SVG executed when other users viewed the file. Because JWT tokens were stored in LocalStorage, the script could read and send them to an attacker, enabling account takeover.

hossein.za68 Follow

Published on medium.com

A few days ago, I was performing a security assessment on a foreign Learning Management System (LMS) platform. The application was developed using a RESTful API architecture, so I initially focused my testing efforts on analyzing different API endpoints.

Hossein Zarei, 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 upload endpoint accepted SVG files without sanitisation and served them from the application's own origin, while authentication tokens were stored in JavaScript-accessible LocalStorage.

Impact

Any user who viewed the malicious SVG had their JWT token stolen, allowing the attacker to access their account without credentials; the report demonstrated this against a second test account.

What the attacker needed

A user account; ability to upload a profile picture; victim views the uploaded SVG

The fix

The application should block or sanitise SVG uploads, serve user files from a separate origin, and store authentication tokens in HttpOnly cookies instead of LocalStorage.

How it was found

  1. Intercept the profile image upload request and replace the normal image with an SVG file containing a script.
  2. Upload the SVG and note the file path returned by the server.
  3. Open the uploaded SVG URL in a browser and observe the script executing.
  4. Confirm that JavaScript can read the JWT token from LocalStorage.
  5. Set up a server to receive and log tokens, and test it with a fetch request from the browser console.
  6. Upload the final SVG payload and verify that visiting its URL sends the victim's JWT token to the attacker's server.

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 contain JavaScript. The site let people upload SVGs as profile pictures and showed them to other users without cleaning them, so the hidden script ran in the victim's browser. The login token was kept in a place JavaScript can read, so the script stole it and the attacker could log in as the victim.

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 hossein.za68

View all

2 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.