Skip to content
XSS Write-up Beginner

Bypassing File Upload Restrictions to Achieve XSS in a Crypto App

The upload endpoint accepted an HTML file even though the interface only allowed image extensions, and the stored file was served from a web-accessible directory and rendered as HTML. An attacker could upload a page containing script that runs in a victim's browser session when the file is opened.

Yamini Yadav_369 Follow

Published on infosecwriteups.com

During a routine internal security assessment of a crypto-based web application within our company, I encountered a file upload functionality that, at first glance, seemed well-restricted. The user interface was designed to only accept image files such as .png, .jpg, and .jpeg formats, and it clearly blocked files…

Yamini Yadav_369, 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 backend trusted the file extension and client-side checks and served uploaded files from a web-accessible directory without content-type restrictions or sandboxing.

Impact

An attacker could run arbitrary script in a logged-in user's session, potentially stealing session tokens or showing fake login and wallet pages, and stored links could make it persistent.

What the attacker needed

Access to the profile upload feature; victim opens the uploaded file URL

The fix

The report says the issue was fixed by the internal team and recommends backend content validation, strict allowlists, randomised names, a non-web-accessible upload directory, a strict CSP and disabling HTML rendering.

How it was found

  1. Upload a normal image through the profile form and intercept the request to find the upload endpoint.
  2. Send the intercepted request to Repeater and confirm the server returns success and stores the file at a predictable URL.
  3. Create a local HTML file containing a script payload.
  4. Send the HTML file to the same endpoint with a different HTTP method and a binary body.
  5. Replace the image file name in the stored URL with the HTML file name and open it in a browser.
  6. Observe the script executing 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 write-up has not been written yet. The Original tab links to the source.

A file upload form let people send pictures, but the server did not really check what kind of file arrived. The tester sent a web page containing a small script instead of a picture, and the server saved it and later showed it as a normal web page, so the script ran in the browser. That kind of script running in someone else's session is called cross-site scripting.

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 Yamini Yadav_369

View all

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