I Found Remote Code Execution in a Cookie & Earned $5000! (Full
A session cookie contained Base64-encoded JSON with a role field that could be changed to admin, granting admin access. An internal debug console then executed commands from a debug field in the cookie, leading to remote code execution.
Published on theindiannetwork.medium.com
In one of my recent bug bounty hunts, I stumbled upon a severely vulnerable web application where a cookie parameter led to full Remote Code Execution (RCE). The vulnerability was completely undetected by automated scanners, making it a goldmine for manual testing.
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 trusted client-side cookie data for authorisation and passed a cookie field directly to a command execution function without validation.
Impact
An attacker could gain admin access and then execute arbitrary commands on the server, leading to full remote code execution.
What the attacker needed
Access to the web application; ability to modify cookies
How it was found
- Inspect the session cookie and notice it is Base64-encoded.
- Decode the cookie to reveal JSON with user and role fields.
- Change the role to admin, re-encode, and refresh to gain admin access.
- Add a debug field containing a system command to the cookie, re-encode, and send the request to execute commands.
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 cookie is a small piece of data a website stores in your browser to remember you. Here, the cookie was just encoded text, not locked or signed, so the tester could change their role from user to admin. Then a hidden admin tool ran any command placed in the cookie, letting the tester control the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.