unchecked unserialize usage in WordPress-Functionality-Plugin-Skeleton/functionality-plugin-skeleton.php
The plugin calls PHP's unserialize on a request body value without restricting which classes may be instantiated. If an attacker could control that value, they could trigger PHP object injection (POP chain) exploitation or abuse known unserialize bugs in older PHP versions.
- Triaged in 15 hours
- Fixed in 38 hours
- Paid in 27 hours
- Disclosed after 32 days
there is usage of unserialize function
public function block_plugin_updates( $request, $url ) {
if ( 0 !== strpos( $url, self::PLUGIN_UPDATE_CHECK_URL ) ) // todo moving to https at some point, if hasn't already
return $request;
$plugins = unserialize( $request['body']['plugins'] ); // todo use json now -- http://make.wordpress.org/core/2013/10/25/json-encoding-ssl-api-wordpress-3-7/
without disallowing unneeded classes. thus, if attacker managed to control the value of $request['body']['plugins'] he will be able to:
1. conduct PHP POP exploitation, more information:
http://www.slideshare.net/_s_n_t/php-unserialization-vulnerabilities-what-are-we-missing http://www.slideshare.net/MailRuGroup/security-meetup-22-php-unserialize-exploiting
2. unserialize itself has many security bugs in previous PHP versions which can be exploited, more information:
https://www.evonide.com/fuzzing-unserialize/ https://blog.checkpoint.com/wp-content/uploads/2016/08/Exploiting-PHP-7-unserialize-Report-160829.pdf
fix:
1. don't use serialize/unserialize if json_encode/json_decode can be used instead. (fix both 1 & 2 attack vectors) 2. if 1 isn't possible, use safe unserialize invocation, such as:
if (version_compare(PHP_VERSION, '7.0', 'lt')) {
return safeUnserialize($data);
} else {
return safeUnserialize($data, false);
}
Implement safeUnserialize function that based on PMA_safeUnserialize: https://github.com/phpmyadmin/phpmyadmin/blob/fb161a7bebe60d902f743227158eca6a9889c472/libraries/core.lib.php#L1080 but with fix for the issue described in: https://hackerone.com/reports/181315#activity-1322058
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the code unserialises untrusted request data without passing an allowed-classes list, so arbitrary PHP objects can be created.
Impact
An attacker who could control the request body value could achieve PHP object injection and possibly code execution, though the report only states this conditionally and does not demonstrate reachability.
What the attacker needed
Attacker controls request body plugins value
The fix
The code should stop using serialize/unserialize in favour of JSON, or if that is not possible, call unserialize with the allowed-classes option set to false on PHP 7 and above.
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 report has not been written yet. The Original tab links to the source.
PHP can turn a stored object back into a live object with a function called unserialize. If a program does that on data a stranger can supply, the stranger may be able to create objects of classes the code never expected, and some of those objects do dangerous things when they are created or destroyed. The report says this could let an attacker run harmful code, but it does not show that the value is actually reachable by an outsider.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.