A simple file upload bypass causing XSS attack
A file upload feature accepted a filename with an extra extension, so an uploaded image was served as HTML and its script ran in the browser. An attacker could upload a crafted file and have it execute script in the context of the site.
Published on medium.com
Today I will continue to share about XSS vulnerabilities caused by file uploads. It’s not difficult at all; once you see it, you’ll understand.
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 validation only checked the final extension and the server served the file with a content type based on the name, allowing HTML and script to be rendered.
Impact
An attacker could run script in a victim's browser when the uploaded file is viewed, potentially stealing session data or performing actions as the user.
What the attacker needed
Ability to upload a file; victim opens the uploaded file
How it was found
- Intercept the file upload request.
- Change the filename to include an extra .html before .png.
- Upload the modified file and open it to trigger script execution.
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.
When you upload a picture, the site usually checks the file name to decide how to show it. Here the check only looked at the last part of the name, so a file ending in .html.png was treated as a picture but still opened as a web page. That let the file's own script run as if it came from the site.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.