Skip to content
File upload Write-up Beginner

Remote Code Execution via Misconfigured File Upload Using Encrypted Payload (AK47WebShell)

Two file upload endpoints accepted a PHP file without proper validation, and the server leaked the uploaded file's path in responses. An attacker could upload a web shell and execute arbitrary commands on the server.

maheshwaripuneet028 Follow

Published on medium.com

While monitoring a production instance, we identified a critical oversight in the application’s file upload mechanisms—one that could have catastrophic consequences. File upload features are frequently under-secured, and this instance was no exception.

Puneet Maheshwari, 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 endpoints lacked proper file type and extension validation, and the server disclosed the uploaded file's path in responses.

Impact

An attacker could execute arbitrary system commands, exfiltrate sensitive data, install persistent backdoors, and potentially move laterally or escalate privileges.

What the attacker needed

Valid user account; access to upload features

The fix

The report recommends strict file validation, storing uploads outside the web root, not disclosing file paths, and disabling script execution in upload directories.

How it was found

  1. Log in and go to the News section upload feature.
  2. Upload a PHP file; the server renames it but discloses the path in the response.
  3. Access the disclosed path in a browser to execute the shell.
  4. Alternatively, go to Profile Settings and upload a PHP file as an avatar.
  5. The upload response does not show the path; update profile info and intercept the response to find the path.
  6. Access the leaked path 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 users upload files but did not check what kind of file it was. The attacker uploaded a PHP script (a program that runs on the server) and then found its location because the server told them the path. By visiting that path, the script ran and gave the attacker control of 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.