Object injection vulnerability enables remote code execution in WordPress 3.6
WordPress stored user-supplied metadata without proper serialization checks, allowing an attacker to inject a serialized PHP object via a crafted string containing an astral Unicode character. When the metadata was later retrieved, the string was unserialized, enabling PHP object injection that could lead to remote code execution if a suitable gadget chain from a plugin was present.
vagosec.org
Published on vagosec.org
After reading a blog post about a “PHP object injection” vulnerability in Joomla, I dug a bit deeper and found Stefan Esser’s slides of the 2010 BlackHat conference, which showed that PHP’s unserialize() function can give rise to vulnerabilities when supplied user-generated content.
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 is_serialized() check was too strict about the last character, and MySQL's utf8 charset silently truncated data after an astral symbol, so a string that failed the check on insert passed it on retrieval.
Impact
An attacker could inject arbitrary PHP objects, and with a suitable plugin class, this could lead to remote code execution; however, the author did not find a core WordPress gadget chain and withheld the plugin exploit details.
What the attacker needed
A user account with profile editing; ability to set a meta field (e.g., first name); a vulnerable plugin with a gadget chain for RCE
The fix
The is_serialized() function was updated to accept a strict parameter and use a less strict check when called from maybe_unserialize(), so that strings with trailing characters are still recognised as serialized and re-serialized on insert.
How it was found
- Set a user meta field (e.g., first name) to a serialized value followed by an astral Unicode character.
- Save the profile; WordPress stores the string without re-serializing because is_serialized() returns false.
- MySQL truncates the string at the astral character, storing only the serialized part.
- On page load, WordPress retrieves the stored value, is_serialized() now returns true, and unserialize() is called.
- The injected object is instantiated, triggering magic methods like __wakeup() and __destruct().
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's unserialize() function turns a stored string back into a PHP value, including objects. If an attacker can control that string, they can create objects with properties they choose, and when the object's methods run, harmful actions may occur. WordPress tried to prevent this by checking if a string looks serialized before storing it, but a quirk in MySQL's utf8 character set allowed bypassing that check.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.