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.
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…
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
- Upload a normal image through the profile form and intercept the request to find the upload endpoint.
- Send the intercepted request to Repeater and confirm the server returns success and stores the file at a predictable URL.
- Create a local HTML file containing a script payload.
- Send the HTML file to the same endpoint with a different HTTP method and a binary body.
- Replace the image file name in the stored URL with the HTML file name and open it in a browser.
- 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.