Skip to content
XSS Write-up Beginner

Stored XSS via Vulnerable File Upload Functionality

The application let users upload files for a purchase-order complaint, and client-side checks on file type could be bypassed by editing the request. An uploaded HTML file was then served back as an HTML document, so script inside it ran in the browser of anyone who opened the file's URL.

medium.com

Published on medium.com

During a recent penetration test, I discovered a stored Cross-Site Scripting (XSS) vulnerability tied to a file upload feature. What initially appeared to be a simple content upload mechanism turned out to be a serious attack vector that could result in arbitrary script execution in the application’s user context.

Shaunak Natu, on medium.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 server stored uploaded files and served them back with a content type the browser rendered as HTML, without server-side validation of file type or content.

Impact

Script in the uploaded file could run in the browser of any user who opened the file's URL, though the tester only demonstrated script execution and did not achieve remote code execution.

What the attacker needed

Ability to submit the complaint form; a proxy to edit the upload request; victim opens the uploaded file's URL

The fix

The upload should be validated on the server side and files served with headers that force download and stop content sniffing, so the browser never renders them as HTML.

How it was found

  1. Submit the purchase-order complaint form with a file attachment.
  2. Intercept the upload request with a proxy and change the file type to bypass client-side checks.
  3. Upload an HTML file and open its direct URL to see the script 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 file upload feature let people attach documents. The site checked the file type only in the browser, so a tester changed the request to send other file types. When an HTML file was uploaded and opened by its direct link, the browser treated it as a normal web page and ran the script inside it, which is stored 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.

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.