Skip to content
RCE Write-up Advanced

OpenCart <= 1.5.6.4 (cart.php) PHP Object Injection Vulnerability

The shopping cart code unserialises a value taken from the user's cart session data without validating it. An attacker who can control that cart key could supply a crafted serialised object and trigger PHP object injection.

karmainsecurity.com

Published on karmainsecurity.com

The vulnerable code is located in the Cart::getProducts() method defined in /system/library/cart.php:

The author, on karmainsecurity.com

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 cart code passes a user-influenced cart key straight into unserialize() after base64-decoding it, with no validation of the serialised data.

Impact

An attacker able to control the cart key could achieve PHP object injection, which may lead to further exploitation depending on the classes available.

What the attacker needed

Control over the cart session key value

The fix

The code should not unserialise user-influenced data; it should validate or replace the serialised cart options with a safe format.

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 a piece of text back into a live object, a process called unserialising. If a program does that with text a user can influence, the user may be able to create objects the developer never intended, which can lead to further attacks. Here the cart code does this on data kept in the shopper's session.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.