Discovery
The WebGoat 8 deserialization challenge blindly deserializes a user-supplied Base64-encoded Java object, allowing an attacker to execute arbitrary commands via a gadget chain. The authors achieved a reverse shell by modifying ysoserial to generate a working Hibernate 5 payload.
medium.com
Published on medium.com
By Ahmed Sherif & Francesco Soncina
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
The application deserializes untrusted user input without validation, allowing a gadget chain to execute arbitrary code.
Impact
An attacker could execute arbitrary commands on the server, leading to a reverse shell and full compromise of the application container.
What the attacker needed
Access to the vulnerable endpoint; ability to send crafted serialized objects
How it was found
- Scan the remote endpoint with the Java-Deserialization-Scanner Burp plugin, which reports Hibernate 5 as potentially vulnerable.
- Modify ysoserial to include the javax.el package and rebuild with the hibernate5 profile.
- Generate a payload with ysoserial using the Hibernate1 chain and Base64-encode it.
- Send the payload to the vulnerable endpoint and verify command execution by checking the Docker container.
- Enumerate available binaries on the target; only Perl and Bash are present.
- Modify Gadgets.java in ysoserial to embed a Bash reverse shell command, rebuild, and send the new payload to obtain a reverse shell.
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.
Java serialization turns objects into a stream of bytes so they can be saved or sent. If a program turns those bytes back into objects without checking where they came from, an attacker can craft bytes that make the program run their commands. This is called insecure deserialization.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.