Skip to content
XSS Write-up Intermediate

Arbitary File Upload too Stored XSS - Bug Bounty

The upload form only checked the declared content type and looked for the PDF magic bytes anywhere in the file, so a file with an HTML extension containing a PDF header and JavaScript was accepted. When the uploaded file was opened through the preview, the script ran in the application's origin, giving stored cross-site scripting.

m0chan Follow

Published on web.archive.org

{{media:0}}

m0chan, on web.archive.org

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 trusted the client-supplied content type and searched for the PDF signature anywhere in the body without checking the file extension or where the signature sat, and the preview then served the file as HTML.

Impact

An attacker could run script in the context of the application when a victim opened the uploaded file, though only HTML files were interpreted and the files were not stored on the web server itself.

What the attacker needed

Access to the upload form; victim opens the uploaded file

The fix

The issue was resolved after being triaged and rewarded.

How it was found

  1. Find the form that only allows PDF attachments.
  2. Upload a file whose declared type is PDF and which contains the PDF marker inside its content.
  3. Upload an HTML file containing the PDF marker plus script, and open it through the preview.
  4. 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 website let people upload files it claimed must be PDFs. It only checked the label the browser attached and looked for a short PDF marker somewhere inside the file, not the file's real type or extension. The author uploaded a web page disguised this way, and when it was opened the browser ran the hidden script as if the site itself had written it.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by m0chan

View all

1 more disclosed report, best first.

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.