Deserialization in Perl v5.8
A hidden form parameter contained a Base64-encoded Storable serialised object. On Perl 5.8, the object's class name was passed to a require statement evaluated as Perl code, allowing an attacker to inject and execute arbitrary commands.
Published on agarri.fr
During a pentest, I found an application containing a form with a hidden parameter named "state". Encoded as Base64, it contains a few strings and some binary data:
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 Storable module passed the attacker-controlled object class name to a require statement that was evaluated as Perl code, instead of safely loading the module.
Impact
An attacker could execute arbitrary commands on the server, as demonstrated by reading system files and running commands through a webshell.
What the attacker needed
Perl 5.8 or older; Attacker controls a serialised parameter
The fix
The issue was fixed in later Perl versions by replacing the evaluated require with a safer module loading call.
How it was found
- Find a hidden Base64-encoded parameter containing serialised data.
- Decode it and identify the Storable format and Perl version.
- Craft a serialised object whose class name contains Perl code after a module name.
- Base64-encode the payload and submit it in the parameter.
- Observe command execution in the response.
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.
Serialisation turns an object into a string so it can be stored or sent. When the application later turns that string back into an object, it may trust the class name inside it. On old Perl versions, that name was run as code, so an attacker could make the server execute commands.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.