Skip to content
File upload Write-up Intermediate

From File Upload to Remote Code Execution: A Step-by-Step Breakdo

The profile picture upload accepted arbitrary files without server-side type validation and served the originals from a public, executable storage directory. An authenticated user could upload an executable file and access it directly to get code execution on the server.

Muhammad Taha Khan Follow

Published on medium.com

I was able to achieve Remote Code Execution (RCE) via the file upload functionality on Academico.

Muhammad Taha Khan, 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 the client and stored files in a web-served directory where the server would execute them, with no real file-type check.

Impact

Critical: an authenticated user could fully compromise the server, read credentials and data, modify files, and possibly pivot to internal systems, though the author notes this depends on hosting and configuration.

What the attacker needed

An authenticated account; ability to upload a profile picture

The fix

Uploads should be stored outside the webroot or in object storage, served only through a controller, validated against a strict allowlist with real content checks, and the upload directory should never execute scripts.

How it was found

  1. Upload a valid image and observe it is converted and served with a thumb suffix.
  2. Upload an SVG and note the conversion fails but the original file is still served.
  3. Upload an executable file and see the conversion fail while the original is stored.
  4. Request the original file through the public storage URL and confirm the server serves it.
  5. Pass a command parameter and observe its output in the response, confirming execution.

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 a profile picture but never checked what kind of file it really was. It also kept the uploaded file in a folder the web server would happily run as a program. So someone could upload a small program instead of a picture and then open it in the browser, making the server run their code.

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.