Skip to content
RCE Write-up Intermediate

How I DIDN’T get an RCE in a $200 Billion company — Bug Bounty

A known critical vulnerability in KRAMER VIAware allowed unauthenticated file write and remote code execution via unfiltered input to a PHP endpoint. The hunter found a matching host, executed a command to prove code execution, but the target turned out to be a honeypot and the report was rejected.

nynan Follow

Published on medium.com

The original lives on medium.com

We do not hold its text, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

CVE-2021-36356 is a critical vulnerability in the KRAMER VIAware software that allows unauthenticated remote code execution. The flaw is in the /ajaxPages/writeBrowseFilePathAjax.php endpoint, which accepts unfiltered input and writes it to a file. The researcher was hunting for this CVE across a subdomain list of over 1,000,000 subdomains and got a hit.

Banner: How I DIDN’T get an RCE in a $200 Billion Dollar Company
Banner: How I DIDN’T get an RCE in a $200 Billion Dollar Company From the original on medium.com

Setup

The researcher used a large subdomain list (over 1,000,000 entries) to search for hosts running the vulnerable KRAMER VIAware software. The report mentions an interactsh server used to receive callbacks and a server owned by the researcher to receive wget requests. No accounts, roles or specific software versions are described.

Finding it

The researcher was scanning for CVE-2021-36356 across the subdomain list and eventually got a hit. The endpoint /ajaxPages/writeBrowseFilePathAjax.php accepts unfiltered input and writes it to a file, which is the root of the vulnerability.

Exploitation

Step 1: Craft the payload

The POST parameter radioBtnVal is where the PHP code is supplied. The researcher used it to upload a bind shell, noting that a reverse shell is also possible but a bind shell is less intrusive and more appropriate for a proof of concept during bug bounties. The POST parameter associateFileName is where the file is written; the researcher advises placing it somewhere accessible from the web server, such as /var/www/html/.

Combining these two parameters gives the payload:

php shell payload
php shell payload From the original on medium.com

When URL encoded, the payload becomes:

From the original on medium.com

Step 2: Execute commands

With the bind shell written, the researcher could send GET requests to /bindShell.php?cmd= to execute commands. These commands are not reflected in the response, so a separate method is needed to prove execution.

Step 3: Prove execution with wget

The researcher used the wget command to call out to a server they own. If the server receives a request, wget was executed, and therefore RCE is confirmed. The researcher sent HackerOne a bug report with a picture showing that the wget command had been run.

From the original on medium.com

Step 4: The triager's response

The triager responded with the following:

From the original on medium.com

The researcher notes that a command had been executed on the company server, but the triager appeared to mistake it for a P5 SSRF bug. The researcher acknowledges that triagers are often under time constraints and make mistakes, and that the report could have been more explicit about what was happening.

Step 5: A clearer proof of concept

To make the demonstration unambiguous, the researcher decided to exfiltrate harmless information as a PoC by running the whoami command and sending the result to their server.

From the original on medium.com

Instead of calling out to the server with a regular response, the researcher crafted the payload $(whoami).domain.com, so that the server resolves $(whoami) and prefixes the request with the answer. The host that runs wget has the name "alana", and the response received on the interactsh server contains the new data. This proves that the server has run a command.

Step 6: Unexpected results

When the researcher performed this on the target, they received lots of hostnames. This was confusing: data was definitely being exfiltrated, but too much of it. The researcher initially thought they might be executing commands on some sort of distributed hosting system, but suspected there was another answer.

From the original on medium.com

After waiting, the researcher finally got a response: they were inside a honeypot.

Root cause

The vulnerability exists because /ajaxPages/writeBrowseFilePathAjax.php accepts all unfiltered input and writes it to a file. The radioBtnVal parameter supplies the content (PHP code) and associateFileName supplies the destination path, allowing an attacker to write an executable PHP file into a web-accessible directory. The report does not describe any additional defences that were present or bypassed; the endpoint simply does not filter input.

Impact

An unauthenticated attacker can achieve remote code execution on a host running the vulnerable KRAMER VIAware software, provided the endpoint is reachable and the written file lands in a web-accessible location. In this case, however, the researcher was inside a honeypot, so the practical impact on the target is unclear. The researcher raises several questions about the honeypot: why a bug bounty program would have a honeypot on in-scope assets, whether it is for threat detection (the researcher asks why they were not blocked), whether it is for collecting traffic for threat analysis (which would be inflated by bug bounty traffic), and how a hunter is supposed to know they are in a honeypot.

Fix

The report does not state what fix, if any, was applied. Based on the described root cause, the endpoint should validate and sanitise input so that user-supplied content cannot be written to arbitrary paths, and should restrict file writes to safe, non-executable locations.

Variants to test

  • Other KRAMER VIAware endpoints that accept file paths or content and write to disk: a positive result is a file appearing at a chosen path with attacker-controlled content.
  • Using $(command).domain.com style payloads to exfiltrate command output via DNS or HTTP callbacks: a positive result is a callback containing the command output.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

A security researcher was looking for a specific known weakness in a piece of software called KRAMER VIAware. They searched a very long list of website names (over 1,000,000 of them) until they found one that had the weakness. They then used that weakness to make the server run a command of their choosing, which is called remote code execution, or RCE. They reported it to the company's bug bounty programme, but the triager appeared to mistake it for a P5 SSRF bug. The researcher sent a clearer proof, and in the end discovered that the machine they had been attacking was not a real company server at all: it was a honeypot, a decoy set up to look like a vulnerable system.

Banner: How I DIDN’T get an RCE in a $200 Billion Dollar Company
Banner: How I DIDN’T get an RCE in a $200 Billion Dollar Company From the original on medium.com

This article walks through the whole story from the beginning, explaining every term as it comes up.

Some background ideas first

Before the steps, here are the ideas you need. You can skim this and come back to it.

  • Server: a computer somewhere on the internet whose job is to answer requests from other computers. When you open a website, your browser asks a server for the page and the server sends it back.
  • Web request: the message your browser sends to a server. A GET request is the ordinary kind, used when you type an address or click a link: you are asking to get something. A POST request is used when you submit a form: you are sending data to the server, for example a username and a password.
  • Parameter: a named piece of data sent with a request. Think of a form with labelled boxes: the label is the parameter name and what you type in the box is its value. In a POST request the values travel in the body of the message; in a GET request they often appear in the address after a question mark.
  • Endpoint: a specific address on a server that does a specific job, like a particular counter in a bank. The endpoint in this story is /ajaxPages/writeBrowseFilePathAjax.php.
  • PHP: a programming language used to build many websites. A file ending in .php is normally executed by the web server: the server runs the code inside it and sends the result to the visitor. That is why writing a PHP file into a place the web server can reach is dangerous.
  • Shell: a way to type commands into a computer and have them run. A bind shell is a small program that, once running on the victim machine, lets the attacker connect to it and type commands. A reverse shell is similar but the victim machine connects back out to the attacker instead. The researcher chose a bind shell because it is less intrusive, which matters when you are only trying to prove a problem exists.
  • RCE (remote code execution): the ability to make someone else's computer run commands or code that you chose, from a distance. It is one of the most serious kinds of weakness because the attacker is no longer limited to what the website intended to offer.
  • CVE: a public catalogue number for a known security flaw, so that everyone can refer to the same issue unambiguously. CVE-2021-36356 is the one in this story.
  • Subdomain: the part in front of a main domain name. In shop.example.com, shop is a subdomain of example.com. Large companies own many of them, which is why a list of over a million is useful for finding forgotten machines.
  • Bug bounty programme: a scheme where a company invites outside researchers to look for security problems in its systems and report them, often for a reward. The company decides which systems are allowed to be tested; those are the in-scope assets. Anything not on the list is out of scope and must be left alone.
  • Triager: the person at the bug bounty platform who reads incoming reports first and decides how serious they are and who should handle them.
  • Proof of concept (PoC): a small, safe demonstration that a problem is real, without causing harm.
  • Out-of-band callback: proof that arrives by a different route than the normal response. If you ask a server to fetch a page from a machine you control, and your machine sees the request arrive, that is a callback: it proves the server really did what you asked, even if it never told you so directly.
  • Honeypot: a decoy system made to look vulnerable and interesting, so that anyone attacking it is drawn in and observed instead of reaching anything real.

The weakness being hunted

CVE-2021-36356 is a critical flaw in KRAMER VIAware. The report says the problem is that the endpoint /ajaxPages/writeBrowseFilePathAjax.php accepts all input without filtering it and writes that input to a file. In everyday terms: imagine a hotel reception where you can ask for a note to be placed in any room, and the receptionist never checks what the note says or which room you named. If one of those rooms is the room where the hotel's own staff read instructions, you have effectively written instructions for the staff.

Here the two things the attacker controls are:

  1. The content that gets written, supplied through the POST parameter radioBtnVal.
  2. The destination path, supplied through the POST parameter associateFileName.

Because the content can be PHP code and the destination can be a folder the web server serves to visitors, the attacker can plant a program on the server and then ask for it in a browser, which makes the server run it.

Finding a vulnerable host

The researcher was searching for this CVE across a subdomain list of over 1,000,000 subdomains, and eventually got a hit. In other words, out of a huge list of machine names belonging to many organisations, one of them was running the vulnerable KRAMER VIAware software and answered on the vulnerable endpoint. The researcher later asks why a bug bounty programme would have a honeypot on in-scope assets.

The report does not describe the scanning tool used, any accounts, or specific software versions.

Step 1: Building the payload

The plan is to use the two parameters together. radioBtnVal carries the PHP code, which will be a bind shell. associateFileName carries the path where the file should be written. The researcher advises choosing a location the web server can serve, giving /var/www/html/ as an example. On a typical Linux web server, that folder is where the public website files live, so anything placed there can be requested by a browser.

Combining the two parameters gives the payload:

php shell payload
php shell payload From the original on medium.com

What this means, piece by piece:

  • The request is a POST to the vulnerable endpoint, so the server treats the values as form data to be processed.
  • radioBtnVal holds the PHP program. When the server later runs this file, the program starts a bind shell, waiting for the attacker to connect and type commands.
  • associateFileName holds the path. The server writes the content of radioBtnVal into a file at that path. Choosing a web-served folder means the file can be reached over the web afterwards.

The same payload, when URL encoded, becomes:

From the original on medium.com

URL encoding is how special characters are made safe to travel inside a web request. A space becomes %20, for example, and other symbols get their own % codes. The server decodes them back to the original characters before using them, so the meaning of the payload does not change; only its appearance in transit does. This step matters because raw code contains characters that would otherwise confuse the request.

Step 2: Running commands through the shell

Once the file is written, the researcher can send GET requests to /bindShell.php?cmd= to execute commands. The cmd parameter is where the command goes: the bind shell takes whatever follows it and runs it on the server.

There is a catch. The commands are not reflected, meaning the output is not sent back in the response. If you imagine shouting an instruction into a room and getting no reply, you cannot tell from the silence whether anyone heard you. So a different way of proving execution is needed.

Step 3: Proving it with wget

wget is a command-line program that fetches something from a web address. The researcher used it to make the server call out to a server the researcher owns. The logic is simple: if the researcher's own server receives a request, then wget must have run on the company machine, and if wget ran, then arbitrary commands can run, which is RCE.

The researcher sent HackerOne a bug report with a picture showing that the wget command had been run.

From the original on medium.com

This is a classic out-of-band proof. You do not need the victim to tell you anything; you just need your own machine to observe the knock at the door.

Step 4: The triager's reply

The triager responded with the following:

From the original on medium.com

A command had been executed on the company server, but the triager appeared to mistake it for a P5 SSRF bug. SSRF means server-side request forgery: tricking a server into making a request to a destination of the attacker's choosing. It is a real weakness, but a much milder one than RCE, and P5 is the lowest severity rating on the platform's scale. The researcher notes that triagers work under time pressure and make mistakes, and accepts that the report could have been more explicit about what was actually happening.

Step 5: A clearer proof of concept

To remove any doubt, the researcher decided to exfiltrate harmless information as a PoC: run the whoami command, which simply prints the name of the user the server is running as, and send that name to the researcher's server.

From the original on medium.com

The trick is in how the name is sent. Instead of calling out to the server with a plain request, the researcher crafted the payload $(whoami).domain.com. The $(...) syntax means "run this command and put its output here". So the server first works out the answer to whoami, then builds a hostname that starts with that answer and ends with the researcher's domain, and then tries to look that hostname up. The lookup reaches the researcher's listening server, which records the hostname it was asked about. The answer to whoami therefore arrives inside the hostname itself.

The host that runs wget has the name "alana", and the response received on the interactsh server contains the new data. Interactsh is a service for catching exactly this kind of out-of-band callback. The result proves that the server has run a command, and it even shows which user ran it.

Step 6: Too many answers

When the researcher performed this on the target, they received lots of hostnames. That was confusing: data was definitely being exfiltrated, but there was too much of it. At first the researcher thought they might be executing commands on some sort of distributed hosting system, a setup where one address is served by many machines. But they suspected there was another answer.

From the original on medium.com

After waiting, the researcher finally got a response: they were inside a honeypot.

A honeypot is a decoy. It is built to look like an attractive, vulnerable machine so that anyone probing it spends time there instead of on real systems, and so that the people running it can watch what attackers do.

Why the weakness exists

The root cause is that /ajaxPages/writeBrowseFilePathAjax.php accepts all unfiltered input and writes it to a file. The radioBtnVal parameter supplies the content, which can be PHP code, and associateFileName supplies the destination path. Together they let an attacker write an executable PHP file into a folder the web server serves. The report does not describe any additional defences that were present or bypassed; the endpoint simply does not filter its input.

What the impact would be

An unauthenticated attacker, meaning someone with no account or login of any kind, can achieve remote code execution on a host running the vulnerable KRAMER VIAware software, as long as the endpoint is reachable and the written file lands somewhere the web server can serve. In this particular case the researcher was inside a honeypot, so the real-world impact on the target is unclear.

The researcher raises several questions about the honeypot:

  1. Why does a bug bounty programme have a honeypot on in-scope assets, the very systems researchers are invited to test?
  2. If it is there to detect threats, the researcher asks why they were not blocked.
  3. If it is there to collect traffic for threat analysis, would not all the legitimate bug bounty traffic inflate the data?
  4. How is a bug bounty hunter supposed to know they are in a honeypot, or must they simply waste time sending reports that go nowhere?

The programme did not seem keen on answering these questions.

What the fix would look like

Based on the described root cause, the endpoint should validate and sanitise its input so that user-supplied content cannot be written to arbitrary paths, and it should restrict file writes to safe locations where the web server will not execute what is written.

Other things worth testing

  • Other KRAMER VIAware endpoints that accept file paths or content and write to disk. A positive result is a file appearing at a path you chose, containing content you chose.
  • Using $(command).domain.com style payloads to carry command output out through DNS or HTTP callbacks. A positive result is a callback that contains the command's output.

Glossary

  • Bind shell: a small program placed on a victim machine that lets an attacker connect to it and type commands.
  • Bug bounty programme: a scheme where a company invites outside researchers to find and report security problems in its systems, often for a reward.
  • Callback (out-of-band): a request arriving at a machine the attacker controls, used as proof that the victim machine performed an action.
  • CVE: a public catalogue number for a known security flaw.
  • Endpoint: a specific address on a server that performs a specific job.
  • Exfiltration: getting data out of a system, here by smuggling it inside a hostname lookup.
  • GET request: an ordinary web request asking to retrieve something, used when you type an address or click a link.
  • Honeypot: a decoy system made to look vulnerable so that attackers are drawn in and observed.
  • In-scope asset: a system a bug bounty programme explicitly allows researchers to test.
  • Interactsh: a service that catches out-of-band callbacks so a researcher can see them.
  • KRAMER VIAware: the software product containing the vulnerable endpoint.
  • Out-of-band: proof that arrives by a different route than the normal response.
  • Parameter: a named piece of data sent with a web request, like a labelled box on a form.
  • PHP: a programming language used to build websites; .php files are executed by the web server.
  • POST request: a web request that sends data to the server, as a form submission does.
  • Proof of concept (PoC): a small, safe demonstration that a problem is real.
  • P5: the lowest severity rating on the bug bounty platform's scale.
  • RCE (remote code execution): making someone else's computer run commands or code you chose, from a distance.
  • Reverse shell: like a bind shell, but the victim machine connects out to the attacker instead.
  • Server: a computer on the internet whose job is to answer requests from other computers.
  • SSRF (server-side request forgery): tricking a server into making a request to a destination of the attacker's choosing.
  • Subdomain: the part in front of a main domain name, as in shop.example.com.
  • Triager: the person at a bug bounty platform who first reads a report and decides how serious it is.
  • URL encoding: replacing special characters with % codes so they can travel safely inside a web request.
  • wget: a command-line program that fetches something from a web address.
  • whoami: a command that prints the name of the user the machine is running as.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.