PHP deserialization attacks and a new gadget chain in Laravel
The article explains PHP object deserialisation and gadget chains, then describes how the authors identified a new gadget chain in the Laravel framework during an engagement. A gadget chain passed to unserialise() lets an attacker instantiate objects that abuse magic methods and application logic, which can lead to code execution.
Published on blog.quarkslab.com
Posted Tue 13 February 2024 Author Mathieu Farrell Category Pentest Tags pentest, framework, PHP, 2024
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 passes user-controlled data to PHP's unserialise() function, allowing crafted serialised objects to trigger magic methods and a chain of gadget classes.
Impact
A crafted serialised string could instantiate objects and drive a gadget chain, potentially leading to code execution, though the article's detail on the Laravel chain is cut off in the provided text.
What the attacker needed
User-controlled data reaches unserialise(); a gadget chain exists in loaded code
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.
PHP can turn an object into a text string (serialise) and turn that string back into an object (unserialise). If a website passes user-supplied text to unserialise(), an attacker can craft the text so that the objects created trigger special methods automatically, and a chain of such objects can make the application do something harmful. This article walks through those building blocks and a new chain found in the Laravel framework.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.