Our Proactive Monitoring Caught a Persistent Cross-Site Scripting (XSS) Vulnerability in a WordPress Plugin
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 one of the most serious vulnerabilities, a persistent cross-site scripting (XSS) vulnerability in the plugin WIP Custom Login.
The automated portion of that monitoring flagged the following line of code because of the possibility that it could permit PHP object injection to occur:
153 | $options = unserialize(file_get_contents($_FILES["wip_custom_login_upload_file"]["tmp_name"])); |
When we manually reviewed the code surrounding that, we found that there was a security check that could limit access to that, but that there were no security checks for other code running in the same function. That was a big concern since the function, save_option(), handles saving the plugin’s settings. Things get worse though, as the function runs during admin_init, which means it will even run for someone not logged in to WordPress:
22 | add_action('admin_init', array(&$this, 'save_option') ,11); |
As the proof of concept below confirms, this could lead to persistent XSS, when JavaScript code is saved as a setting’s value.
This is the relevant code in the function save_option(), which is located in the file /core/includes/class-panel.php, that handles saving of the setting done in the proof of concept:
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | if ( $this->wip_custom_login_request('wip_custom_login_action') == "Save" ) { foreach ( $this->panel_fields as $element ) { if ( isset($element['tab']) && $element['tab'] == $_GET['tab'] ) { foreach ($element as $value ) { if ( isset($_REQUEST['element-opened']) && $_REQUEST['element-opened'] == "Skins" ) { $get_skin = wip_custom_login_jsonfile("skins.json"); $current = $get_skin[$_REQUEST["wip_custom_login_skins"]]; $message_action = esc_html__('Options saved successfully.'); update_option( $this->plugin_optionname, array_merge( $wip_custom_login_setting ,$current) ); break; } else if ( isset( $value['id']) ) { if ( isset($_POST[$value["id"]]) ) : $current[$value["id"]] = $_POST[$value["id"]]; else : $current[$value["id"]] = ""; endif; update_option( $this->plugin_optionname, array_merge( $wip_custom_login_setting ,$current) ); } $message_action = esc_html__('Options saved successfully.', 'wip-custom-login' ); } } } |
Missing from the plugin’s code to handle saving the settings are a capabilities check, a nonce check, and some combination of sanitization, validation, and escaping.
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 cause an alert box with any available cookies to be shown on the page /wp-admin/admin.php?page=wip_custom_login_panel&tab=Form.
Replace “[path to WordPress]” with the location of WordPress.
<html> <body> <form action="http://[path to WordPress]/wp-admin/admin-post.php?tab=Form" enctype="multipart/form-data" method="POST"> <input type="hidden" name="wip_custom_login_loginbox_width" value='"><script>alert(document.cookie);</script>' /> <input type="hidden" name="wip_custom_login_action" value="Save" /> <input type="submit" value="Submit" /> </form> </body>