In plain English: unserialize() can create objects of classes named inside
the input. If an attacker controls that input, they may choose a class with
dangerous __wakeup() or __destruct() methods. This is called object
injection.
Why it matters: Object injection can lead to file writes, command execution, or other side effects depending on which classes the application loads.
$cart = unserialize($_COOKIE['cart']);
$cart = unserialize($payload, []);
$cart = unserialize($payload, ['allowed_classes' => true]);
$cart = unserialize($payload, ['allowed_classes' => false]);
$dto = unserialize($payload, [
'allowed_classes' => [Cart::class, CartItem::class],
]);
allowed_classes => false prevents object creation and allows only arrays and
scalars. A list allows only the classes you name.
unserialize($payload) with no options argumentallowed_classes keyallowed_classes => true, which explicitly allows every classunserialize(data: $payload, options: [...])allowed_classes is false or a list of class names.unserialize(serialize($value)), a local round-trip.unserialize(), set allowed_classes to false or to a
short list of expected classes.unserialize().E0053 has no configuration options and is enabled by default.