Skip to content
RCE Write-up Intermediate

Remote Code Execution via Cookie Manipulation

A cookie named 'portfolio' held a URL-encoded Perl data structure that the server deserialised, and the attacker could place a system call inside that structure to run commands on the server. The author confirmed command execution by receiving a callback with the server's username.

medium.com

Published on medium.com

Remote Code Execution (RCE) is a common vulnerability, often stemming from file upload functionalities where users upload PHP files that get executed on the server. While the general concept of RCE and its potential risks are widely covered in many resources, I won’t be revisiting those details here.

Geni_Wazir, 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 application deserialised a user-controlled cookie value into a Perl data structure without validation, allowing embedded code such as a system call to be evaluated.

What the attacker needed

Ability to intercept and modify requests; a valid session cookie

The fix

The application should not deserialise untrusted cookie data into executable structures; it should store only opaque, signed identifiers and validate them server-side.

How it was found

  1. Inspect the cookies while browsing the webapp and find the 'portfolio' parameter with a URL-encoded value.
  2. Decode the value and observe it is a Perl data structure.
  3. Insert a system call into the structure and re-encode it.
  4. Replace the cookie value in the intercepted request and forward it.
  5. Observe a 500 error but a callback to the collaborator confirming execution.
  6. Run further commands such as hostname and local IP retrieval to confirm.

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.

Some web servers store settings in a cookie, a small piece of data the browser sends back on every request. Here the server took that cookie text and turned it back into a program data structure without checking it, so the tester could slip in an instruction that runs a command on the server. That is remote code execution: an outsider gets the server to run their commands.

What is RCE?

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

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.