Skip to content
File upload Write-up Intermediate

Alhamdulillah ❤️

The file upload system lacked limits on file size and count, allowing an attacker to exhaust server storage and potentially crash it. The server also validated PDFs only by magic bytes, so a file with a valid header followed by an XSS payload was accepted and the payload executed on the site.

medium.com

Published on medium.com

During my analysis of a website, I identified two major vulnerabilities that could severely impact the server:

MOAMEN REZK, 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 upload handler trusted only the file's magic bytes and imposed no size or count limits, and it never cleaned up stored files.

Impact

An attacker could consume server storage and potentially crash it, and could execute script in the context of the site through an uploaded PDF.

What the attacker needed

Access to the file upload feature; ability to upload files

The fix

The upload handler should validate file extensions, sizes and dimensions, scan full file content rather than only magic bytes, enforce strict limits on number and size of uploads, and regularly clean up old files.

How it was found

  1. Upload an excessively large file to the site.
  2. Observe that the server accepts it without any size restriction.
  3. Create a file starting with valid PDF magic bytes followed by an XSS payload.
  4. Upload the file with a .pdf extension.
  5. Observe the XSS payload executing and reflecting on the website.

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 should check what a file really is, not just its first few bytes. Here the site trusted a short signature at the start of the file, so someone could hide harmful script content after it. Separately, the site never limited how big or how many files could be uploaded, so someone could fill up the server's disk.

What is File upload?

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.