Stored XSS via PNG Polyglot Upload and Filename Trust
The application validated uploaded files as PNG images but stored them using the attacker-controlled filename extension, so a PNG polyglot containing HTML/JavaScript could be saved as .html and served as active content. An attacker could then execute arbitrary JavaScript in the browser of anyone who opened the uploaded file URL.
medium.com
Published on medium.com
A few months ago I came across an interesting stored XSS vulnerability while testing a profile picture upload feature on a website that has since been taken offline.
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
Impact
Arbitrary JavaScript execution could potentially allow session theft, phishing, credential harvesting, or unauthorised actions on behalf of affected users, depending on their privileges.
What the attacker needed
Ability to upload a profile picture; victim opens the uploaded file URL
How it was found
- Intercept the profile picture upload request.
- Upload a valid PNG file that also contains embedded HTML/JavaScript.
- Change the multipart filename extension from .png to .html while leaving the Content-Type as image/png.
- Submit the upload, which is accepted.
- Open the generated URL for the uploaded file directly in a browser, causing the embedded JavaScript to execute.
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 profile pictures. It checked that the file was really an image, but then saved it using whatever name the uploader chose. By uploading a file that was both a valid image and contained a script, and naming it with a .html ending, the site later served it as a web page, so the script ran in the browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.