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.
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
- Inspect the cookies while browsing the webapp and find the 'portfolio' parameter with a URL-encoded value.
- Decode the value and observe it is a Perl data structure.
- Insert a system call into the structure and re-encode it.
- Replace the cookie value in the intercepted request and forward it.
- Observe a 500 error but a callback to the collaborator confirming execution.
- 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.