Our Proactive Monitoring Caught an Arbitrary File Upload Vulnerability in a Brand New WordPress Plugin
One way we help to improve the security of WordPress plugins, not just for our customers, but for everyone using them, is the proactive monitoring of changes made to plugins in the Plugin Directory to try to catch serious vulnerabilities. That has led to us catching a vulnerability of a type that hackers are likely to exploit if they know about it.
This vulnerability is in a brand new plugin, Wireless Butler, and should have been something that the review that is supposed to be done before new plugins can be added to the Plugin Directory should have caught. It is something that would have been flagged by our Plugin Security Checker, so it would make sense to run plugins through that during that security review to avoid this type of situation continuing to happen. That it continues to happen speaks to the continued lack of interest in improving security by the leadership of WordPress (starting at the top with Matt Mullenweg) and the continued role we play in limiting the impact of that for everyone else. We would be happy to provide the Plugin Directory team free access to all of that tool’s capabilities and have repeatedly offered to do that, but we haven’t been taken up on that.
What our monitoring flagged was this line of code:
162 | move_uploaded_file($_FILES['bill']['tmp_name'], $dirname .'/'. $filename); |
That code handles upload sent with a request, but it doesn’t use WordPress functionality for handling file uploads, which protects against certain security issue, so additional security code would be needed to properly restrict the ability to upload files through that. Looking at the code that runs before that shows the additional security code isn’t in place.
That code runs in function named handle_form_1_step_1_submit(), which is accessible whether someone is logged in to WordPress or isn’t logged in:
112 113 | add_action( 'admin_post_nopriv_wireless_butler_form_1_step_1', array($this, 'handle_form_1_step_1_submit') ); add_action( 'admin_post_wireless_butler_form_1_step_1', array($this, 'handle_form_1_step_1_submit') ); |
The function itself, which is located in the file /public/class-wireless-butler-public.php, doesn’t restrict what types of files can be uploaded through it:
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | function handle_form_1_step_1_submit($data) { global $table_prefix, $wpdb; $data = array_map( 'sanitize_text_field', $_POST ); $returnData = array(); $billFileURL = ''; $manual = $data['manual']; if($manual == '0') { $upload_dir = wp_upload_dir(); if ( ! empty( $upload_dir['basedir'] ) ) { $dirname = $upload_dir['basedir'].'/wireless-butler'; if ( ! file_exists( $dirname ) ) { wp_mkdir_p( $dirname ); } $filename = wp_unique_filename( $dirname, $_FILES['bill']['name'] ); |
So a hacker could, for example, upload a .php file with malicious code and then run that code.
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
Add the plugin’s shortcode to a post or page. When logged out of WordPress, submit the resulting form with a .php file as the file included with that. That file will be uploaded to the directory /wp-content/uploads/wireless-butler/.