Hitting the jackpot with RCE!
A test endpoint allowed uploading PHP files without restriction, and the uploaded files were stored in a publicly listable directory. An attacker could upload a PHP script that executes arbitrary system commands, leading to remote code execution.
Published on medium.com
Hey, so everyone was pushing me to write another write-up after the acceptance of my first ever bug bounty write up. So if you haven’t already read it please have a look at it here: https://medium.com/@gokulsspace/the-30000-bounty-affair-3f025ee6b834
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.
Context
This is a story about an unrestricted file upload that turned into remote code execution on a host belonging to a large company, referred to throughout as redacted.com. The host was not part of the program's main scope, and the bounty was adjusted downwards for that reason. The researcher describes it as their second RCE of 2023.
The vulnerable feature was not a designed product surface at all. It was a path called test that a developer had set up as a playground for testing, with file upload options left in place and no restrictions on what could be uploaded.
Setup
The report does not describe any accounts, roles, credentials or specific tool versions. The only tooling mentioned is subdomain enumeration and content discovery: the researcher names Subfinder, Amass, knockpy and securitytrails as examples of enumeration tools and says the choice does not matter, then describes fuzzing the discovered host with a wordlist to find hidden paths and files. No wordlist, fuzzer or version is specified.
The precondition for the whole chain is finding a host that is interesting enough to fuzz and that exposes a writable, web-served upload directory.
Finding it
The starting point was subdomain enumeration against a large company. The researcher's advice is to watch for hosts that return default pages of Nginx, Apache or Red Hat, and singles out Nginx default pages as worth attention.
On one such host, the researcher fuzzed with a wordlist to look for hidden paths and files. That surfaced a path called test:
The researcher describes it as a messy endpoint where the developer had done rough work for testing purposes, and notes that it offered a few options to upload files.

The screenshot sits next to the description of the test endpoint and its upload options.
Exploitation
Step 1: upload a PHP file
Normally, uploading anything other than an image or a document means fighting upload restrictions and trying bypass ideas that often fail. Here there were no restrictions at all, because the endpoint was a developer's test area. The researcher uploaded a random PHP file called test.php and it succeeded.
Step 2: find where uploads are stored
The next question was where the uploaded file lands. Fuzzing http://redacted.com/test/ again revealed a directory index of uploaded files at:
The uploaded test.php was listed there.
Step 3: upload a web shell
With storage and execution location confirmed, the researcher created a second PHP file called rce.php containing a command execution payload:
<?php system($_GET["cmd"]);?>
This script takes the value of the cmd GET parameter from the request and passes it to system(), which runs it as a shell command on the server and returns the output in the HTTP response. Any visitor who can reach the file can therefore run commands with the privileges of the web server user.
Step 4: verify execution
The file was uploaded and confirmed present in the uploads index. The researcher then called it with a cmd parameter to prove code execution:

The researcher ran whoami through the uploaded file to verify the RCE.
A second command listed the working directory in long format:

The %20 is a URL-encoded space, so the server receives ls -la. The researcher then ran ls -la through the same file.

That completed the chain. The researcher notes that the target was not in the main scope of the program, so the bounty was adjusted to be a little low.
Root cause
The endpoint accepted files of any type, including .php, and stored them inside a directory that the web server both listed and executed. Two separate mistakes combine here: no validation of the uploaded file's extension or content on the server side, and an upload directory placed under the document root with PHP execution enabled. The exposed directory index at /test/plain/uploads made the stored files easy to locate, but it is not what made execution possible; the missing upload restriction and the executable storage location did.
The report frames the cause as the endpoint being a developer's test area with no restrictions on the kind of files that could be uploaded. Whether any validation existed elsewhere and was simply absent here is not stated.
Impact
An attacker who finds the endpoint can upload arbitrary PHP and run operating system commands on the host as the web server user, reading files and directories and, by extension, doing anything that user is permitted to do. In this case the researcher only ran whoami and ls -la to demonstrate it.
The practical limit is reachability: the host has to be discoverable and the test path has to be found, which in this case took subdomain enumeration plus fuzzing. The report also notes that the asset was outside the program's main scope, which affected the reward rather than the severity of the flaw itself.
Fix
The report does not say what the company changed. Based on the root cause, the fixes would be to reject uploads whose extension or content type is not on an allowlist, to store uploads outside the document root or in a location where script execution is disabled, and to remove the directory index. Which of these were actually applied is not stated.
Variants to test
- Fuzz default pages on newly enumerated subdomains for paths named after environments or roles, such as
test,dev,stagingorupload. A positive result is a directory listing or an upload form that accepts a file without complaint. - Upload a harmless PHP file such as
test.phpand then look for a directory index of uploads. A positive result is the file appearing in a listing under a path served by the web server. - If the upload is accepted, request the stored file directly. A positive result is the PHP being executed rather than returned as source, which you can confirm with a payload that prints a value you control.
- Try alternate executable extensions where PHP is filtered, for example
.phtml,.php5or.phar, and check whether the server still executes them. A positive result is the same command output as with.php. - Check whether the upload directory allows overwriting an existing file by reusing its name. A positive result is the previously stored file being replaced by your upload.
What happened, in plain words
A security researcher found a test area on a company's website that let anyone upload files. Because the test area was set up by a developer for quick testing, it had no protections. The researcher uploaded a small program written in PHP (a language used to build websites) that could run commands on the server. By visiting that file in a browser and adding a command in the web address, the researcher proved they could run commands on the server. This kind of flaw is called remote code execution (RCE). The company adjusted the bounty downwards because the affected host was not part of the program's main scope.
Finding the test area
The researcher started by looking for subdomains of a large company (called redacted.com here). A subdomain is a prefix added to a domain name, like blog.example.com or shop.example.com. Companies often have many subdomains, and some are forgotten or left in a default state. The researcher used tools such as Subfinder, Amass, knockpy and securitytrails to list subdomains, but says the choice of tool does not matter. The important thing is to find a host that looks interesting enough to explore further.
One common sign of an interesting host is a default welcome page from a web server such as Nginx, Apache or Red Hat. These pages often mean the server has not been fully configured. The researcher found such a page and decided to fuzz it. Fuzzing means sending many requests with a list of common words (a wordlist) to guess hidden paths and files. It is like trying many door handles in a building to see which ones open.
Fuzzing revealed a path called test:
This is a web address. http:// is the protocol, redacted.com is the domain, and /test/ is the path on the server. The researcher describes this endpoint as messy, a place where a developer had done rough work for testing. It offered a few options to upload files.

The screenshot sits next to the description of the test endpoint and its upload options.
Exploitation
Step 1: upload a PHP file
Normally, websites restrict what you can upload. They might allow only images or documents, and they check the file's extension (the part after the dot, like .jpg) or its content. Bypassing those checks can be hard. Here, there were no restrictions at all because the endpoint was a test area. The researcher uploaded a random PHP file called test.php and it succeeded. PHP is a programming language that runs on the web server; a .php file is a script that the server executes when someone requests it.
Step 2: find where uploads are stored
The next question was where the uploaded file goes. The researcher fuzzed http://redacted.com/test/ again and found a directory index of uploaded files at:
A directory index is a web page that lists the files in a folder, like opening a folder on your computer and seeing its contents. The uploaded test.php was listed there. This confirmed two things: the file was stored inside the website's document root (the folder that the web server serves to visitors), and the directory listing was turned on, making files easy to find.
Step 3: upload a web shell
With the storage location confirmed, the researcher created a second PHP file called rce.php containing this code:
<?php system($_GET["cmd"]);?>
Let us break it down:
<?phpand?>mark the start and end of PHP code inside a file.$_GET["cmd"]reads the value of a parameter namedcmdfrom the web address. For example, if the address ends with?cmd=whoami, then$_GET["cmd"]equalswhoami.system(...)is a PHP function that runs a command on the server's operating system and prints the output.
So this script takes whatever command you put in the cmd parameter and runs it on the server. Anyone who can reach the file can run commands with the same permissions as the web server user. This kind of script is often called a web shell.
Step 4: verify execution
The file was uploaded and appeared in the uploads index. The researcher then called it with a cmd parameter to prove that code execution worked:

whoami is a command that prints the name of the user running the process. The researcher ran whoami through the uploaded file to verify that commands executed.
A second command listed the current directory in long format:

%20 is how a space is encoded in a web address, so the server receives ls -la. The ls command lists files, and -la asks for a long listing including hidden files. The researcher then ran ls -la through the same file.

That completed the chain. The researcher notes that the target was not in the main scope of the program, so the bounty was adjusted to be a little low.
Why it worked
The endpoint accepted files of any type, including .php, and stored them in a directory that the web server both listed and executed. Two mistakes combine: no validation of the uploaded file's extension or content on the server side, and an upload directory placed under the document root with PHP execution enabled. The exposed directory index made the files easy to locate, but it is not what allowed execution; the missing upload restriction and the executable storage location did.
The report frames the cause as the endpoint being a developer's test area with no restrictions on the kind of files that could be uploaded. Whether any validation existed elsewhere and was simply absent here is not stated.
Impact
An attacker who finds the endpoint can upload arbitrary PHP and run operating system commands on the host as the web server user. That means reading files and directories and, by extension, doing anything that user is permitted to do. In this case the researcher only ran whoami and ls -la to demonstrate it.
The practical limit is reachability: the host has to be discoverable and the test path has to be found, which took subdomain enumeration plus fuzzing. The report also notes that the asset was outside the program's main scope, which affected the reward rather than the severity of the flaw itself.
Fix
The report does not say what the company changed. Based on the root cause, the fixes would be to reject uploads whose extension or content type is not on an allowlist, to store uploads outside the document root or in a location where script execution is disabled, and to remove the directory index. Which of these were actually applied is not stated.
Variants to test
- Fuzz default pages on newly enumerated subdomains for paths named after environments or roles, such as
test,dev,stagingorupload. A positive result is a directory listing or an upload form that accepts a file without complaint. - Upload a harmless PHP file such as
test.phpand then look for a directory index of uploads. A positive result is the file appearing in a listing under a path served by the web server. - If the upload is accepted, request the stored file directly. A positive result is the PHP being executed rather than returned as source, which you can confirm with a payload that prints a value you control.
- Try alternate executable extensions where PHP is filtered, for example
.phtml,.php5or.phar, and check whether the server still executes them. A positive result is the same command output as with.php. - Check whether the upload directory allows overwriting an existing file by reusing its name. A positive result is the previously stored file being replaced by your upload.
Glossary
- Subdomain: a prefix added to a domain name, like
blog.example.com. - Fuzzing: sending many requests with a list of common words to guess hidden paths and files.
- Wordlist: a list of words used in fuzzing.
- Endpoint: a specific web address that a server responds to.
- PHP: a programming language that runs on web servers.
- Web shell: a script that lets an attacker run commands on a server through a web interface.
- RCE (Remote Code Execution): a flaw that lets an attacker run their own code on a server.
- Directory index: a web page that lists the files in a folder.
- Document root: the folder on a server that the web server serves to visitors.
- GET parameter: a value passed in the web address after a
?, like?cmd=whoami. - URL encoding: representing special characters in a web address, such as
%20for a space. - Bounty: a reward paid by a company for reporting a security flaw.
- Scope: the set of targets that a bug bounty program allows you to test.