$4,998 Bounty Awarded and 100,000 WordPress Sites Protected Against Unauthenticated Remote Code Execution Vulnerability Patched in GiveWP WordPress Plugin
The GiveWP WordPress plugin unserialised untrusted input from the 'give_title' parameter, allowing unauthenticated attackers to inject a PHP object. A POP chain in the plugin enabled remote code execution and arbitrary file deletion.
Published on wordfence.com
On May 26th, 2024, we received a submission for an unauthenticated PHP Object Injection to Remote Code Execution vulnerability in GiveWP, a WordPress plugin with more than 100,000 active installations. This vulnerability can be leveraged via an existing POP chain present in the plugin to execute code remotely and…
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.
Context
GiveWP is a WordPress donation plugin with more than 100,000 active installations. It provides customisable donation forms, donor management, reporting and integrations with third-party payment gateways. Donations are handled by the give_process_donation_form() function, which validates the submitted post data, builds a $donation_data array and hands the payment off to the selected gateway with give_send_to_gateway(). As part of that processing the plugin also creates a donor record and stores donor meta, including a title prefix taken from the donation form.
The vulnerability described here is an unauthenticated PHP Object Injection that, combined with POP chains already present in the plugin and its bundled libraries, leads to remote code execution and arbitrary file deletion. It was reported through the Wordfence Bug Bounty Program and assigned CVE-2024-5932 with a CVSS score of 10.0 (Critical), vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H. Affected versions are all releases up to and including 3.14.1; the fully patched version is 3.14.2. The researcher, villu164, earned a bounty of $4,998.00.
Setup
No account, role or special tooling is required to reach the vulnerable path: the injection point is in the donation form processing, which is reachable without authentication. The only precondition is a site running GiveWP 3.14.1 or earlier. The researcher supplied a proof-of-concept exploit that includes a POP chain payload invoking shell_exec() and uploading a web shell to the server.
Finding it
The starting point is the validation performed at the beginning of give_process_donation_form(). The function calls give_donation_form_validate_fields(), which checks whether the post data contains serialised values using give_donation_form_has_serialized_fields():
if (give_donation_form_has_serialized_fields($post_data)) {
give_set_error('invalid_serialized_fields', esc_html__('Serialized fields detected. Go away!', 'give'));
}
The check exists to reject serialised input, but in the vulnerable version it does not include the give_title post parameter. That omission is what makes the rest of the chain reachable: a serialised value placed in give_title passes validation untouched.
Exploitation
Step 1: get the title into the user data
After validation, give_process_donation_form() calls give_get_donation_form_user(), which contains this snippet:
if ( empty( $user['user_title'] ) || strlen( trim( $user['user_title'] ) ) < 1 ) {
$user['user_title'] = ! empty( $post_data['give_title'] ) ? strip_tags( trim( $post_data['give_title'] ) ) : '';
}
When no user title is otherwise set, the value of the give_title post parameter is trimmed, passed through strip_tags() and stored as the user's user_title. The serialised payload therefore travels from the request into the $user array.
Step 2: carry it into the donation data
The function then builds $donation_data, which includes $user_info derived from the earlier $user values, and calls give_send_to_gateway():
$donation_data = [
'price' => $price,
'purchase_key' => $purchase_key,
'user_email' => $user['user_email'],
'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
'user_info' => stripslashes_deep( $user_info ),
'post_data' => $post_data,
'gateway' => $valid_data['gateway'],
'card_info' => $valid_data['cc_info'],
];
give_send_to_gateway( $donation_data['gateway'], $donation_data );
Step 3: persist the serialised value as donor meta
While the payment data is processed, the donor is added through the insert() function in the DonorRepository class:
DB::table('give_donors')
->insert($args);
$donorId = DB::last_insert_id();
foreach ($this->getCoreDonorMeta($donor) as $metaKey => $metaValue) {
DB::table('give_donormeta')
->insert([
'donor_id' => $donorId,
'meta_key' => $metaKey,
'meta_value' => $metaValue,
]);
}
private function getCoreDonorMeta(Donor $donor): array
{
return [
DonorMetaKeys::FIRST_NAME => $donor->firstName,
DonorMetaKeys::LAST_NAME => $donor->lastName,
DonorMetaKeys::PREFIX => $donor->prefix ?? null,
];
}
The prefix meta is written to the database under the key _give_donor_title_prefix, and its value is the serialised form of the user title that was set from give_title. The attacker-controlled serialised string is now stored server-side.
Step 4: trigger deserialisation
Still within payment processing, the _give_donor_title_prefix meta is read back with get_meta() inside the setup_user_info() function of the Give_Payment class, which unserializes the stored value:
$user_info[ $key ] = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true );
At this point the injected object is instantiated, and any magic methods on the classes in the payload run. The researcher's exploit uses this to invoke shell_exec() and upload a web shell.
The POP chain for remote code execution
The complete PHP POP chain is shown in the diagram below.

The source code in the snippets is shortened for readability, so only the relevant functions appear.
The chain starts with Give\PaymentGateways\DataTransferObjects\GiveInsertPaymentData, which holds a $userInfo array property. Its getLegacyBillingAddress() function reads the address element of that array and queries billing address properties from the resulting object:
namespace Give\PaymentGateways\DataTransferObjects;
final class GiveInsertPaymentData
{
public $userInfo;
private function getLegacyBillingAddress()
{
$donorDonationBillingAddress = $this->userInfo['address'];
$address = [
'line1' => $donorDonationBillingAddress->address1,
'line2' => $donorDonationBillingAddress->address2,
'city' => $donorDonationBillingAddress->city,
'state' => $donorDonationBillingAddress->state,
'zip' => $donorDonationBillingAddress->zip,
'country' => $donorDonationBillingAddress->country,
];
if (! $donorDonationBillingAddress->country) {
$address = false;
}
return $address;
}
}
$userInfo['address'] can be set to an instance of the Give class. That class has a $container property, and its __get() magic method forwards any property access, such as the address1 lookup above, to the container's get() method:
class Give
{
public function __get( $propertyName )
{
return $this->container->get( $propertyName );
}
}
The $container property can in turn be set to an instance of Give\Vendors\Faker\ValidGenerator. That class has $generator, $validator and $maxRetries properties, and its __call() magic method, triggered when get() is invoked on it, calls call_user_func_array() on the generator and then call_user_func() on the validator:
namespace Give\Vendors\Faker;
class ValidGenerator
{
public function __call($name, $arguments)
{
$i = 0;
do {
$res = call_user_func_array([$this->generator, $name], $arguments);
++$i;
if ($i > $this->maxRetries) {
throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a valid value', $this->maxRetries));
}
} while (!call_user_func($this->validator, $res));
return $res;
}
}
By pointing $validator at shell_exec(), the attacker gets arbitrary command execution on the server through call_user_func().
The POP chain for arbitrary file deletion
The plugin also loads and uses the TCPDF PHP library for PDF generation. Its destructor performs cleanup:
class TCPDF {
public function __destruct() {
// cleanup
$this->_destroy(true);
}
}
_destroy() contains the following snippet:
foreach($this->imagekeys as $file) {
if (strpos($file, K_PATH_CACHE) === 0 && TCPDF_STATIC::file_exists($file)) {
@unlink($file);
}
}
Each entry in the imagekeys property is passed to unlink(). An attacker who creates a TCPDF object and sets imagekeys can therefore delete files of their choosing when the object is destructed.
Root cause
The primary mistake is that the serialised-field check in give_donation_form_has_serialized_fields() does not cover the give_title post parameter. Untrusted input from that parameter is trimmed and passed through strip_tags() but never rejected for being serialised, and it is then stored as donor meta and later read back with get_meta(), which unserializes it. The plugin's own validation is the defence that fails here; the serialised value simply never reaches the check that would have blocked it.
The second half of the problem is the presence of usable gadget chains in the plugin and its dependencies. GiveInsertPaymentData, Give and ValidGenerator combine into a chain that ends in call_user_func(), and the bundled TCPDF class provides a destructor that calls unlink() on attacker-chosen paths. Without those classes the object injection would be far less useful; with them it becomes code execution and file deletion.
Impact
An unauthenticated attacker can inject a PHP object through the donation form and, using the POP chains, execute arbitrary code remotely and delete arbitrary files. The researcher's exploit demonstrates command execution via shell_exec() and uploads a web shell, and the TCPDF chain allows deletion of files on the server. The CVSS vector reflects network reachability, no privileges or user interaction, and high confidentiality, integrity and availability impact with a scope change. The report's conclusion describes the vulnerability as allowing malicious code execution on the server. Sites running GiveWP 3.14.1 or earlier are exposed until they update.
Fix
The vulnerability was fully addressed in GiveWP version 3.14.2, released on August 7, 2024. The report urges users to update to the latest patched version, 3.14.2 at the time of writing, as soon as possible. Wordfence customers, including those on the free version, are protected against exploits targeting this vulnerability by the firewall's built-in PHP Object Injection protection.
Variants to test
- Other form fields excluded from the serialised-field check. Submit serialised strings in every donation form parameter and watch for values that survive validation and are later unserialized. A positive result is a stored value that comes back as an object rather than a string.
- Other meta keys written from user input. Look for donor or payment meta populated from request data and later read with
get_meta(). A positive result is a round trip from request parameter to unserialize call. - Other gadget chains in bundled libraries. Audit libraries shipped with the plugin, such as TCPDF, for destructors and magic methods that reach
unlink(),call_user_func()or similar sinks. A positive result is a class whose magic method acts on an attacker-controlled property. - Container-style
__get()forwarding. Search for classes that forward property access to a stored object's method, asGive::__get()does. A positive result is a property read that invokes an arbitrary method on an injected object. - Faker-style
__call()wrappers. Look for classes that callcall_user_func()orcall_user_func_array()on stored callables. A positive result is a stored callable that is invoked with attacker-influenced arguments.
What happened, in plain words
GiveWP is a free add-on (a "plugin") for WordPress, the software many websites use to publish blogs and small business sites. GiveWP turns a WordPress site into a donation site: it lets you build donation forms, keep a list of donors, produce reports and connect to third-party payment gateways. More than 100,000 websites had it installed at the time of this report.
In May 2024 a security researcher found a serious flaw in GiveWP. Anyone on the internet, without any account or password, could send a specially crafted donation form submission to a vulnerable site and make the site run commands of the attacker's choosing on its server. The same flaw also let an attacker delete files from the server. The researcher reported it through Wordfence's bug bounty programme, a scheme where companies pay researchers for finding and privately reporting security problems. The researcher, villu164, was paid $4,998.00. The flaw was given the identifier CVE-2024-5932 and a severity score of 10.0 out of 10, the maximum. Versions of GiveWP up to and including 3.14.1 were affected; version 3.14.2, released on 7 August 2024, fixes it.
The technical name for the flaw is "unauthenticated PHP Object Injection to Remote Code Execution". That sounds like a lot, so let us unpack it word by word.
- Unauthenticated means the attacker does not need to log in. No account, no password, no special role on the site.
- PHP is the programming language WordPress and its plugins are written in. It runs on the web server, the computer that stores and serves the website.
- Object Injection is a way of sneaking a piece of PHP data (an "object") into an application through input the application trusts too much. We will explain objects in detail below.
- Remote Code Execution, often shortened to RCE, means the attacker can make the server run commands. That is about as bad as it gets: the attacker is no longer just reading or changing a web page, they are giving orders to the machine itself.
A useful everyday comparison: imagine a hotel receptionist who accepts a sealed envelope from any guest and later opens it in the back office. Normally the envelope contains a room-service order. Object Injection is the trick of putting something else in the envelope, something the back office will act on without checking who sent it. Remote Code Execution is what happens when the thing in the envelope is an instruction to the building's maintenance system.
Background: what a plugin is, and what this plugin does
WordPress itself is a core program. Plugins are add-ons that extend it. When a visitor loads a page on a WordPress site, WordPress and its active plugins run PHP code on the server to build the page and send it back to the browser.
GiveWP's job is donations. A visitor fills in a donation form: name, email, amount, maybe a title such as "Mr" or "Ms", and payment details. The browser sends that form to the server. The server checks it, records the donor, and passes the payment to whichever payment gateway (Stripe, PayPal and so on) the site has configured.
In GiveWP, the function that handles this is called give_process_donation_form(). A function is a named block of code that does one job; you can think of it as a labelled drawer in a filing cabinet. This particular drawer does the whole donation workflow: validate the submitted data, assemble a bundle of information about the donation, and hand it to the gateway.
Background: what PHP Object Injection is
This section explains the class of bug before we look at GiveWP's specific mistake. If you have never programmed, read it slowly; everything later depends on it.
Serialised data
PHP needs to store complex data, for example a shopping basket with several products, in places that only hold plain text: a database column, a settings file, a cookie. To do that it converts the data into a text string. That conversion is called serialisation, and the reverse, turning the string back into live data, is deserialisation (or "unserializing").
A serialised string looks like this:
a:2:{s:11:"productName";s:5:"apple";s:7:"price";i:10;}
Read it piece by piece:
a:2:means "an array with 2 entries". An array is an ordered list of values, each with a key.{ ... }wraps the entries.s:11:"productName"means "a string of 11 characters: productName". A string is text.s:5:"apple"is the value: a 5-character string, apple.s:7:"price"is the second key, 7 characters long.i:10;is the value: an integer (a whole number), 10.
So the whole line says: productName is apple, price is 10. WordPress uses this format for many of its settings, which is why it is everywhere in WordPress code.
Objects, classes and methods
Modern PHP code is object oriented. A class is a template: it describes what pieces of data a thing has and what it can do. The pieces of data are called properties; the actions are called methods. An object is one concrete thing built from that template.
An online shop might have a class Product with properties $price and $productName, and a method to calculate tax. Each real product in the shop is a separate object made from that one template, with its own price and name.
Serialisation can store objects too, not just arrays and strings. That is the door through which the attack walks.
Magic methods
Some methods in PHP are special: the language calls them automatically at certain moments, without the programmer writing a call. These are magic methods, and their names start with two underscores. Two matter here:
__destructruns when an object is no longer needed and PHP cleans it up. Think of a cleaner who comes in after the meeting ends and throws away the notes.__getruns when code tries to read a property that is not directly available on the object. Think of a receptionist who, when asked for something not at the front desk, phones another department.__callruns when code tries to call a method that does not exist on the object. Think of a switchboard operator who forwards a call to whoever can handle it.
The report gives a small example class to show why a magic method can turn a harmless object into a dangerous one. It calculates product prices, writes a log file, and deletes that log file when the object is destroyed:
class Product {
public $price;
public $productName;
public $savedPriceFile;
function __construct( $price, $productName ) {
$this->price = $price;
$this->productName = $productName;
$this->savedPriceFile = $productName . "pricefile.log";
}
function calculateTotal( $quantity ) {
$total = $this->price * $quantity;
echo $total;
file_put_contents( $this->savedPriceFile, $total );
}
function __destruct() {
unlink( $this->savedPriceFile );
}
}
Line by line:
class Product {starts the template named Product.public $price;and the next two lines declare three properties: the price, the product name, and the name of a file where the price is saved.publicmeans any other code may read or write them.function __construct( $price, $productName ) {is the constructor, which runs automatically when a new object is created. It takes the price and name as inputs.$this->price = $price;stores the given price on this object.$thismeans "this particular object".$this->productName = $productName;stores the name.$this->savedPriceFile = $productName . "pricefile.log";builds a file name by gluing the product name and the text pricefile.log together. The dot is PHP's way of joining strings.function calculateTotal( $quantity ) {is a method that takes a quantity.$total = $this->price * $quantity;multiplies price by quantity.echo $total;prints the result.file_put_contents( $this->savedPriceFile, $total );writes the result into the file named in the property.function __destruct() {is the magic method that runs at cleanup time.unlink( $this->savedPriceFile );deletes the file named in the property.unlinkis PHP's file-deletion function.
On its own this class is ordinary. But if an attacker can inject an object of this class through a deserialisation bug, they control the properties, including the file name. The report shows exactly such a payload:
O:7:"Product":3:{s:5:"price";i:2;s:11:"productName";s:6:"apples";s:14:"savedPriceFile";s:13:"wp-config.php";}
Reading it:
O:7:"Product"means "an object of the class whose name is 7 characters long: Product".:3:says the object has 3 properties.s:5:"price";i:2;sets price to the integer 2.s:11:"productName";s:6:"apples";sets the product name to apples.s:14:"savedPriceFile";s:13:"wp-config.php";sets the file name to wp-config.php.
wp-config.php is the WordPress configuration file: it holds the database name, user and password. When the object is eventually destroyed, __destruct runs unlink on that file name and deletes it. The report notes that deleting wp-config.php would reset the site, potentially allowing an attacker to take over by connecting it to a remote database they control.
The lesson: a deserialisation bug plus a class with a useful magic method equals damage. Security people call such a class a gadget, and a chain of gadgets that ends in a dangerous action a POP chain (property-oriented programming chain).
The flaw in GiveWP
The check that was meant to stop this
GiveWP's donation handler begins by validating the submitted form data. It calls a validation function, give_donation_form_validate_fields(), which among other things asks whether any submitted field contains a serialised value, using give_donation_form_has_serialized_fields(). If it finds one, it refuses the donation:
if (give_donation_form_has_serialized_fields($post_data)) {
give_set_error('invalid_serialized_fields', esc_html__('Serialized fields detected. Go away!', 'give'));
}
Line by line:
if (...)means "if the thing in brackets is true, do what follows".give_donation_form_has_serialized_fields($post_data)asks the question: does the submitted data contain serialised values?$post_datais everything the browser sent in the form.give_set_error(...)records an error that stops the donation.'invalid_serialized_fields'is the internal name of the error.esc_html__('Serialized fields detected. Go away!', 'give')is the message shown to the user, prepared safely for display on a web page.
This is a sensible defence. The problem is that the check did not look at every field. In the vulnerable version it did not include the form field named give_title, the donor's title (Mr, Ms and so on). A serialised value placed in give_title therefore sailed straight past the guard. This is the root cause: the one field the check forgot is the one the attacker uses.
Step 1: the title becomes user data
After validation, the handler calls give_get_donation_form_user(), which contains this snippet:
if ( empty( $user['user_title'] ) || strlen( trim( $user['user_title'] ) ) < 1 ) {
$user['user_title'] = ! empty( $post_data['give_title'] ) ? strip_tags( trim( $post_data['give_title'] ) ) : '';
}
Line by line:
if ( empty( $user['user_title'] ) || strlen( trim( $user['user_title'] ) ) < 1 ) {checks whether the user's title is missing or blank.empty()is true when a value is missing or empty.trim()removes spaces from both ends.strlen()counts characters. The||means "or". So: if there is no title, or the trimmed title has fewer than one character, do the next line.$user['user_title'] = ...assigns the title.! empty( $post_data['give_title'] )means "if the submitted give_title field is not empty".? ... : ''is a compact if/else: use the value before the colon if the condition holds, otherwise use an empty string.strip_tags( trim( $post_data['give_title'] ) )trims spaces and removes HTML tags from the submitted value.
So whatever the visitor typed into the title field is cleaned of HTML and stored as the user's title. The serialised payload has now moved from the web request into the plugin's internal $user data. Note what strip_tags does not do: it does not reject serialised text. The value is cleaned, not refused.
Step 2: the title travels with the donation
The handler then assembles a bundle describing the donation and sends it to the payment gateway:
$donation_data = [
'price' => $price,
'purchase_key' => $purchase_key,
'user_email' => $user['user_email'],
'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
'user_info' => stripslashes_deep( $user_info ),
'post_data' => $post_data,
'gateway' => $valid_data['gateway'],
'card_info' => $valid_data['cc_info'],
];
give_send_to_gateway( $donation_data['gateway'], $donation_data );
Line by line:
$donation_data = [ ... ];builds an array (a labelled list) holding everything about this donation.'price' => $price,stores the amount. The=>pairs a label with a value.'purchase_key' => $purchase_key,stores a unique reference for the purchase.'user_email' => $user['user_email'],stores the donor's email.'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),stores the current date and time in a standard format.'user_info' => stripslashes_deep( $user_info ),stores the user information, with backslashes removed from every nested value bystripslashes_deep.'post_data' => $post_data,keeps the original submitted form data.'gateway' => $valid_data['gateway'],records which payment gateway was chosen.'card_info' => $valid_data['cc_info'],records the card details.give_send_to_gateway( $donation_data['gateway'], $donation_data );hands the gateway name and the whole bundle to the function that talks to the payment provider.
Why does this matter for the attack? Because the title, still carrying the serialised payload, is now part of the data the plugin keeps processing. The payload is not stopped; it is carried further into the system.
Step 3: the payload is saved in the database
While the payment is processed, the plugin creates a donor record. The DonorRepository class does this with its insert() function:
DB::table('give_donors')
->insert($args);
$donorId = DB::last_insert_id();
foreach ($this->getCoreDonorMeta($donor) as $metaKey => $metaValue) {
DB::table('give_donormeta')
->insert([
'donor_id' => $donorId,
'meta_key' => $metaKey,
'meta_value' => $metaValue,
]);
}
private function getCoreDonorMeta(Donor $donor): array
{
return [
DonorMetaKeys::FIRST_NAME => $donor->firstName,
DonorMetaKeys::LAST_NAME => $donor->lastName,
DonorMetaKeys::PREFIX => $donor->prefix ?? null,
];
}
Line by line, first block:
DB::table('give_donors')selects the database table that holds donors. A database is the organised store where a website keeps its content and settings; a table is one sheet inside it, like one tab in a spreadsheet.->insert($args);adds a new row (a new donor) using the values in$args.$donorId = DB::last_insert_id();asks the database for the ID number it just assigned to that new row, and remembers it.foreach ($this->getCoreDonorMeta($donor) as $metaKey => $metaValue) {loops over each piece of extra donor information, taking the label ($metaKey) and the value ($metaValue) one at a time.DB::table('give_donormeta')selects the table that stores this extra information, one row per label.->insert([ ... ]);adds a row with three columns: which donor it belongs to (donor_id), the label (meta_key) and the value (meta_value).
Second block:
private function getCoreDonorMeta(Donor $donor): arraydefines a helper that returns the standard extra information for a donor.privatemeans only code inside this class may call it;: arraysays it returns an array.return [ ... ];returns three labelled values.DonorMetaKeys::FIRST_NAME => $donor->firstName,maps the label for first name to the donor's first name.DonorMetaKeys::LAST_NAME => $donor->lastName,does the same for the last name.DonorMetaKeys::PREFIX => $donor->prefix ?? null,maps the label for the title prefix to the donor's prefix, or to nothing (null) if it is not set. The??means "use the left side if it exists, otherwise the right side".
The prefix is the title we controlled. It is written into the database under the key _give_donor_title_prefix, and its value is the serialised form of the title. The attacker's payload is now stored on the server, waiting to be read back.
Step 4: the payload is unpacked
Still during the same payment processing, the plugin reads that stored value back. In the Give_Payment class, the setup_user_info() function calls get_meta():
$user_info[ $key ] = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true );
Line by line:
$user_info[ $key ] =stores the result under a label in the user information array.Give()->donor_metareaches the plugin's donor-meta helper.->get_meta( $donor->id, '_give_donor_title_prefix', true )asks for the meta value belonging to this donor, under the key_give_donor_title_prefix. The finaltrueasks for a single value rather than a list.
Here is the crucial moment. When the plugin reads this stored meta value with get_meta(), it unserializes it, turning the saved serialised object back into a live PHP object. So the string the attacker planted is turned back into a live PHP object. Any magic methods on the classes named in that payload now run. This is the object injection: the attacker's data has become code objects inside the server's memory.
The POP chain for remote code execution
The complete PHP POP chain is shown in the diagram below.

The diagram maps the classes and the order in which they call each other. The code snippets that follow are shortened for readability, so only the relevant functions appear.
First link: GiveInsertPaymentData
The chain starts with a class called Give\PaymentGateways\DataTransferObjects\GiveInsertPaymentData. The backslashes are PHP's way of grouping classes into folders-like namespaces, so this class lives in a nested group called DataTransferObjects. It holds a $userInfo array property, and its getLegacyBillingAddress() function reads the address element of that array and pulls billing address fields from the resulting object:
namespace Give\PaymentGateways\DataTransferObjects;
final class GiveInsertPaymentData
{
public $userInfo;
private function getLegacyBillingAddress()
{
$donorDonationBillingAddress = $this->userInfo['address'];
$address = [
'line1' => $donorDonationBillingAddress->address1,
'line2' => $donorDonationBillingAddress->address2,
'city' => $donorDonationBillingAddress->city,
'state' => $donorDonationBillingAddress->state,
'zip' => $donorDonationBillingAddress->zip,
'country' => $donorDonationBillingAddress->country,
];
if (! $donorDonationBillingAddress->country) {
$address = false;
}
return $address;
}
}
Line by line:
namespace Give\PaymentGateways\DataTransferObjects;declares where this class lives in the plugin's naming scheme.final class GiveInsertPaymentDatastarts the class.finalmeans no other class may extend it.public $userInfo;declares a property that will hold user information.private function getLegacyBillingAddress()defines a method that builds a billing address.$donorDonationBillingAddress = $this->userInfo['address'];takes theaddressentry out of the user information array. In a normal donation this is an address object; in an attack it can be an object of the attacker's choosing.$address = [ ... ];builds an array of address lines.'line1' => $donorDonationBillingAddress->address1,reads theaddress1property from that object. The next lines do the same for line 2, city, state, zip and country.if (! $donorDonationBillingAddress->country) {checks whether the country is empty. The!means "not".$address = false;if there is no country, mark the address as false.return $address;hand the result back.
The important part is the property reads such as ->address1. If $userInfo['address'] is not a real address object but a crafted object, those reads trigger that object's magic methods. That is the hook the attacker uses.
Second link: Give
The $userInfo['address'] entry can be set to an instance of the Give class. That class has a $container property, and its __get() magic method forwards any property read, such as the address1 lookup above, to the container's get() method:
class Give
{
public function __get( $propertyName )
{
return $this->container->get( $propertyName );
}
}
Line by line:
class Givestarts the class.public function __get( $propertyName )defines the magic method that runs whenever code reads a property that is not directly present.$propertyNameis the name of the property being asked for.return $this->container->get( $propertyName );passes the request to the object stored in$container, calling itsget()method with the same name.
So when the first link asks for address1, the Give object does not answer itself; it forwards the question to whatever object sits in $container. The attacker chooses that object. This is the receptionist analogy from earlier: the request is passed to another department, and the attacker decides which department.
Third link: ValidGenerator
The $container property can be set to an instance of Give\Vendors\Faker\ValidGenerator. This class has $generator, $validator and $maxRetries properties. Its __call() magic method runs when a method that does not exist is called on it, for example the get() call forwarded by the previous link. It then uses call_user_func_array() on the generator and call_user_func() on the validator:
namespace Give\Vendors\Faker;
class ValidGenerator
{
public function __call($name, $arguments)
{
$i = 0;
do {
$res = call_user_func_array([$this->generator, $name], $arguments);
++$i;
if ($i > $this->maxRetries) {
throw new \OverflowException(sprintf('Maximum retries of %d reached without finding a valid value', $this->maxRetries));
}
} while (!call_user_func($this->validator, $res));
return $res;
}
}
Line by line:
namespace Give\Vendors\Faker;places the class in the plugin's bundled Faker library, a tool normally used to generate fake test data.class ValidGeneratorstarts the class.public function __call($name, $arguments)is the magic method for calls to methods that do not exist.$nameis the method name,$argumentsthe arguments.$i = 0;starts a counter at zero.do { ... } while (...);is a loop that runs the body at least once and repeats while the condition at the end is true.$res = call_user_func_array([$this->generator, $name], $arguments);calls the method named$nameon the object in$generator, passing the arguments.call_user_func_arrayis a PHP function that calls another function or method by name, with an array of arguments.++$i;increases the counter by one.if ($i > $this->maxRetries) {checks whether the counter has passed the retry limit.throw new \OverflowException(...)raises an error if it has.sprintfbuilds the message text.} while (!call_user_func($this->validator, $res));repeats the loop while the validator call returns false.call_user_func($this->validator, $res)calls whatever function is stored in$validator, passing the result$res.return $res;returns the result once the loop ends.
The dangerous part is call_user_func($this->validator, $res). The attacker controls $validator. By pointing it at PHP's shell_exec() function, which runs a command on the operating system and returns its output, the attacker gets arbitrary command execution on the server. The report says the researcher's exploit uses exactly this to invoke shell_exec() and upload a web shell, a small script that gives the attacker a way back into the site later.
The POP chain for arbitrary file deletion
The plugin also loads and uses the TCPDF PHP library, which generates PDF files. Its destructor performs cleanup:
class TCPDF {
public function __destruct() {
// cleanup
$this->_destroy(true);
}
}
Line by line:
class TCPDF {starts the class.public function __destruct() {defines the magic method that runs when the object is destroyed.// cleanupis a comment, ignored by PHP.$this->_destroy(true);calls the class's own_destroymethod, passingtrue.
_destroy() contains this snippet:
foreach($this->imagekeys as $file) {
if (strpos($file, K_PATH_CACHE) === 0 && TCPDF_STATIC::file_exists($file)) {
@unlink($file);
}
}
Line by line:
foreach($this->imagekeys as $file) {loops over each entry in theimagekeysproperty, calling it$file.if (strpos($file, K_PATH_CACHE) === 0 && TCPDF_STATIC::file_exists($file)) {checks two things.strpos($file, K_PATH_CACHE) === 0asks whether the file path starts with the cache directory constantK_PATH_CACHE(position zero means the very beginning).TCPDF_STATIC::file_exists($file)asks whether the file exists. The&&means both must be true.@unlink($file);deletes the file. The@suppresses error messages.
An attacker who creates a TCPDF object and sets imagekeys can therefore delete files of their choosing when the object is destroyed. The report describes this as arbitrary file deletion.
Why it worked: the root cause in one place
The primary mistake is that the serialised-field check in give_donation_form_has_serialized_fields() did not cover the give_title post parameter. Untrusted input from that parameter was trimmed and passed through strip_tags() but never rejected for being serialised. It was then stored as donor meta and later read back with get_meta(), which unserializes it. The plugin's own validation was the defence that failed; the serialised value simply never reached the check that would have blocked it.
The second half of the problem is the presence of usable gadget chains in the plugin and its dependencies. GiveInsertPaymentData, Give and ValidGenerator combine into a chain that ends in call_user_func(), and the bundled TCPDF class provides a destructor that calls unlink() on attacker-chosen paths. Without those classes the object injection would be far less useful; with them it becomes code execution and file deletion.
Impact
An unauthenticated attacker could inject a PHP object through the donation form and, using the POP chains, execute arbitrary code remotely and delete arbitrary files. The researcher's exploit demonstrates command execution via shell_exec() and uploads a web shell, and the TCPDF chain allows deletion of files on the server. The CVSS vector reflects network reachability, no privileges or user interaction, and high confidentiality, integrity and availability impact with a scope change. Sites running GiveWP 3.14.1 or earlier were exposed until they updated.
The fix
The vulnerability was fully addressed in GiveWP version 3.14.2, released on 7 August 2024. The report urges users to update to the latest patched version, 3.14.2 at the time of writing, as soon as possible. Wordfence customers, including those on the free version, are protected against exploits targeting this vulnerability by the firewall's built-in PHP Object Injection protection.
Variants to test
These are the follow-up checks a security tester would run after finding this bug, written for someone learning the trade.
- Other form fields excluded from the serialised-field check. Submit serialised strings in every donation form parameter and watch for values that survive validation and are later unserialized. A positive result is a stored value that comes back as an object rather than a string.
- Other meta keys written from user input. Look for donor or payment meta populated from request data and later read with
get_meta(). A positive result is a round trip from request parameter to unserialize call. - Other gadget chains in bundled libraries. Audit libraries shipped with the plugin, such as TCPDF, for destructors and magic methods that reach
unlink(),call_user_func()or similar sinks. A positive result is a class whose magic method acts on an attacker-controlled property. - Container-style
__get()forwarding. Search for classes that forward property access to a stored object's method, asGive::__get()does. A positive result is a property read that invokes an arbitrary method on an injected object. - Faker-style
__call()wrappers. Look for classes that callcall_user_func()orcall_user_func_array()on stored callables. A positive result is a stored callable that is invoked with attacker-influenced arguments.
Glossary
- API: an agreed way for one piece of software to ask another to do something, like a menu of requests a program accepts.
- Array: an ordered collection of values, each stored under a label or position.
- Bug bounty programme: a scheme where organisations pay researchers who find and privately report security flaws.
- Callable: a function or method that can be passed around by name and called later.
- Class: a template in object-oriented code describing what data a thing holds and what it can do.
- Constructor: a method that runs automatically when a new object is created.
- Cookie: a small piece of data a website stores in your browser so it can recognise you on later requests.
- CVE: a public identifier for a known security vulnerability, so people can refer to it unambiguously.
- CVSS: a scoring system that rates the severity of a vulnerability, from 0 to 10.
- Database: an organised store of data, made of tables, that a website uses to keep content and settings.
- Deserialisation: turning a stored text string back into live data such as an array or object.
- Destructor: a magic method that runs when an object is no longer needed and is cleaned up.
- Function: a named block of code that performs one job and can be called by name.
- Gadget: an existing class whose methods can be abused as one step in an attack chain.
- Gateway: a payment service such as Stripe or PayPal that actually moves the money.
- Magic method: a method PHP calls automatically at certain moments, with a name starting with two underscores.
- Meta: extra information attached to a record, stored as label and value pairs.
- Method: an action a class or object can perform.
- Namespace: a naming scheme that groups classes together to avoid name clashes.
- Object: one concrete thing built from a class, with its own data.
- Object Injection: sneaking a crafted object into an application through input it deserializes without proper checks.
- PHP: the programming language WordPress and its plugins are written in.
- Plugin: an add-on that extends WordPress.
- POP chain: a sequence of existing classes linked through magic methods that, when triggered by an injected object, ends in a dangerous action.
- Property: a piece of data belonging to an object.
- Remote Code Execution (RCE): making a server run commands of the attacker's choosing.
- Serialisation: converting complex data into a text string so it can be stored or sent.
- Shell: a way to give commands to an operating system.
- String: text.
- Table: one sheet inside a database, like one tab in a spreadsheet.
- Unauthenticated: reachable without logging in or holding any account.
- Unserialize: the act of turning serialised text back into live data.
- Web shell: a small script uploaded to a server that lets an attacker run commands through the website later.
- WordPress: the software many websites use to publish content, which plugins extend.