In October 2023, WPScan published a detailed walkthrough of an RCE gadget chain in WordPress core. The research started from a plausible object-injection sink in wp_termmeta and ended with a chain that reached a callable dispatch primitive using only classes shipped in core. I reproduced the chain and added a WordPress/RCE/1 gadget chain to PHPGGC.
This note is a retrospective on the construction, not a new disclosure. WordPress fixed the relevant unserialize paths in 6.3.2.
wp_termmeta. The reusable part is the object graph that turns maybe_unserialize() into a callable dispatch. Every class in that graph ships with WordPress core.The starting point
The original context was a SQL injection challenge that inserted rows into wp_termmeta. Metadata values are passed through maybe_unserialize() when read back, so an attacker who can write a crafted value may be able to trigger PHP object injection. The usual assumption was that WordPress core had no useful POP chain without a plugin. The research tested that assumption.
The chain begins with WP_Theme::__toString(), which calls $this->display('Name') and then $this->get('Name'). Because the attacker controls the serialized object, WP_Theme’s internal properties can be replaced with other objects, including classes that implement ArrayAccess.
public function __toString() {
return (string) $this->display( 'Name' );
}
The string conversion is the trigger. display() reaches get(), and get() assumes $this->headers is an array. In a crafted object it can be any object implementing ArrayAccess, so the next method call is selected by the attacker.
The pivots
The chain then uses WP_Block_List, whose offsetGet() treats the requested index as a block lookup and can instantiate a WP_Block from attacker-controlled properties. The WP_Block constructor calls WP_Block_Type_Registry::get_registered(), which gives another controlled array lookup.
public function offsetGet( $index ) {
$block = $this->blocks[ $index ];
if ( isset( $block ) && is_array( $block ) ) {
$block = new WP_Block( $block, $this->available_context, $this->registry );
$this->blocks[ $index ] = $block;
}
return $block;
}
That lookup leads back to WP_Theme::offsetGet('Parent Theme'). The method calls $this->parent()->get('Name'), and parent() returns another attacker-controlled object. A WpOrg\Requests\Session object has a compatible get() method, so the chain pivots into the bundled Requests library.
WordPress/RCE/1. Each arrow is a method call that looks ordinary in isolation. The chain works because the serialized payload controls both the class of every object and the values of every property along the path.Session::request() merges attacker-controlled properties into the request options and hands the result to Requests::request(). That method dispatches the requests.before_request hook through $options['hooks']->dispatch(). Since the attacker controls the hooks object, the dispatch can be recursed once to shift parameters and reach a callable of the attacker’s choosing.
Why it worked
Three properties made the chain possible:
- Core shipped many magic methods and
ArrayAccessimplementations that were safe in normal use but composable when an attacker controls the entire object graph. - The Requests library exposed a dispatch hook whose callable was taken from object state.
- The source of the object injection, term metadata, was reachable from a realistic SQL injection primitive.
The chain does not require a plugin, a writable file, or an administrator account. That is what made it worth packaging as a reusable PHPGGC gadget chain rather than treating it as a one-off CTF trick.
The fix
WordPress 6.3.2 changed the classes used in the final chain so that several of them can no longer be unserialized, and restricted what some unserialized properties may contain. The underlying lesson is not specific to WordPress: every class with a magic method or a callback property becomes part of the attack surface for any object-injection sink in the same codebase.
If you are reviewing a PHP application, enumerate the sinks first. unserialize(), maybe_unserialize(), session decoding, cache backends, and queue payloads all qualify. Then look for classes whose destructors, wakeup methods, string conversions, or array access can reach a callable. The sink is usually the easy part to find. The chain is the work.
