Skip to content
File upload Write-up Intermediate

File Upload Restrictions Bypass in S3 Bucket

The S3 bucket's upload policy only checked that a form field named Content-Type started with 'image/', while the actual file's content type was set separately, so an attacker could upload any file type. This allowed hosting of malicious files such as scripts or executables in the bucket.

medium.com

Published on medium.com

The target is like a multi-vendor e-commerce website where, there are 2 types of users. Buyers and Sellers.

SAEED, 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 S3 bucket policy validated only a form field named Content-Type (requiring it to start with 'image/') but did not validate the actual file content or the second Content-Type field that described the uploaded file.

Impact

An attacker could host malicious files (such as scripts or executables) in the S3 bucket and use it as personal storage, potentially increasing costs; the text does not claim code execution on the site itself.

What the attacker needed

A seller account; ability to intercept upload request

The fix

The text says the bug has not been fixed yet; it should be fixed by strict server-side validation that rejects any file which is not an actual image file.

How it was found

  1. Sign up as a seller and go to the product picture upload section.
  2. Capture the upload request in Burp Suite and send it to Repeater.
  3. Notice two Content-Type fields in the multipart body.
  4. Remove the image body and change both Content-Type values to text/plain; the server returns 403 with a policy error.
  5. Change the first Content-Type to start with image/ while keeping the second as the actual file type; the file uploads successfully.
  6. Access the returned Location URL to download or render the uploaded file.

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.

When you upload a picture, the website checks the file type. Here, the check was fooled because the form had two fields both called Content-Type: one was checked by the storage service and the other described the real file. By making the checked field look like an image while the real file was something else, any file could be uploaded.

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.