Skip to content
File upload Write-up Beginner

Easy File Upload Functionality Remote Code Execution

The application allowed uploading a PHP file by changing the Content-Type header, and the uploaded file was executed by the server. An attacker could upload a reverse shell and gain control of the server.

medium.com

Published on medium.com

Hello everyone! I’m Abhishek Pal, and today I want to share a critical vulnerability I discovered during my recent bug hunting.

Abhishek (Bug Hunter), 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 trusted the client-supplied Content-Type header and stored uploaded files in a location where they could be executed.

Impact

An attacker could execute arbitrary code on the server, leading to full system control, data breaches, and network compromise.

What the attacker needed

Access to a file upload feature; ability to intercept HTTP requests

The fix

The application should validate file types on the server side and store uploaded files in a non-executable directory.

How it was found

  1. Visit the target application and find the file upload feature.
  2. Upload a harmless image file to confirm the upload works.
  3. Intercept the upload request with a tool like Burp Suite.
  4. Change the Content-Type header to application/php.
  5. Replace the image content with a PHP reverse shell file.
  6. Forward the request, copy the disclosed URL, and open it in a browser to execute the shell.

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 send files to the server. The server did not check what kind of file it was, so someone uploaded a script that the server then ran. That gave the attacker a way to control the server.

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.