An Interesting Case of XSS Caused by File Upload
The feedback section's image upload accepted a file whose extension was changed to xhtml, and the uploaded file was then served in a way that executed script. An attacker could upload a crafted file and get stored script to run when the file is accessed.
Published on medium.com
Today, I want to share with you an interesting vulnerability I discovered in a bounty project, an XSS caused by file upload.
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 only validated the file extension and did not restrict or sanitise active content types, so an .xhtml file was stored and served as executable markup.
Impact
An attacker could store script that runs when the uploaded file is accessed, though the text does not show whether other users or the site's own pages were affected.
What the attacker needed
Access to the feedback upload form
The fix
The upload should reject active file types and serve uploaded files with a safe content type and download disposition.
How it was found
- Intercept the feedback image upload request.
- Change the file extension in the request to xhtml.
- Upload the file and confirm it is accepted.
- Replace the file content with script and upload again.
- Access the uploaded file to trigger the script.
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 let people upload pictures in a feedback form. The upload check only looked at the file name ending, so renaming the file to end in .xhtml slipped past it. When the uploaded file was opened in a browser, the script inside it ran, which is cross-site scripting (XSS): making a site run someone else's code.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.