Skip to content
XSS Write-up Beginner

Blog Title: Not Your File: How Misconfigured MIME Types Let Me Upload Evil Scripts

The avatar upload endpoint did not validate MIME types server-side, allowing an attacker to upload an SVG file containing JavaScript. When the SVG was rendered as a profile picture or in a preview iframe, the script executed, enabling stored cross-site scripting and potential session cookie theft from internal users.

infosecwriteups.com

Published on infosecwriteups.com

Free Link ๐ŸŽˆ

Iski, on infosecwriteups.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 accepted uploaded files based on the client-supplied Content-Type header without validating the actual file content or restricting dangerous file types like SVG.

Impact

An attacker could execute arbitrary JavaScript in the context of any user who viewed the malicious SVG, including internal users like support agents or admins, potentially stealing session cookies and leading to account takeover.

What the attacker needed

Ability to upload a file; victim views the uploaded file

The fix

The server should validate MIME types server-side, avoid rendering user-uploaded SVG or HTML directly, and serve uploads with Content-Disposition: attachment.

How it was found

  1. Find the avatar upload endpoint.
  2. Upload an SVG file with a script inside, setting the Content-Type to image/svg+xml.
  3. The upload is accepted and the SVG is rendered in the browser, executing the script.
  4. Upload the same SVG as a profile picture to make it persistent.
  5. Any user who views the profile triggers the stored script.
  6. Use a preview endpoint that renders the SVG in an iframe with srcdoc to execute JavaScript and steal cookies.

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 you upload a profile picture. It didn't check what kind of file you uploaded, so someone uploaded a picture that was actually a script. When other people viewed that picture, the script ran in their browser, letting the attacker steal their login cookies.

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.