Another One of the 100 Most Popular WordPress Plugins Has a Security Vulnerability Related to Usage of extract()
On Friday, we noted that five of the 100 most popular WordPress plugins were using the extract() function insecurely. While none of those plugins look to have an obvious vulnerability due directly to the usage of extract(), we mentioned in the previous post that we had confirmed that one of the plugins, with 1+ millions installs, had a vulnerability related to its usage. We have now confirmed that the same type of issue exists in another plugins, Ocean Extra. That plugin is a companion to the OceanWP theme and has 700,000+ installs according to WordPress’ stats.
We tested and confirmed that our upcoming firewall plugin for WordPress protects against the exploitation of this vulnerability.
The plugin registers a shortcode, “oceanwp_breadcrumb”, which calls the function oceanwp_breadcrumb_shortcode():
731 | add_shortcode( 'oceanwp_breadcrumb', 'oceanwp_breadcrumb_shortcode' ); |
In that the function, which is located in the file /includes/shortcodes/shortcodes.php, the extract() function is used on user input in the form of shortcode attributes:
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 | function oceanwp_breadcrumb_shortcode( $atts ) { // Return if is in the Elementor edit mode, to avoid error if ( class_exists( 'Elementor\Plugin' ) && \Elementor\Plugin::$instance->editor->is_edit_mode() ) { return esc_html__( 'This shortcode only works in front end', 'ocean-extra' ); } // Return if is in the admin, to avoid conflict with Yoast SEO if ( is_admin() ) { return; } // Return if OceanWP_Breadcrumb_Trail doesn't exist if ( ! class_exists( 'OceanWP_Breadcrumb_Trail' ) ) { return; } extract( shortcode_atts( array( 'class' => '', 'color' => '', 'hover_color' => '', ), $atts ) ); |
As we noted in the previous post, the documentation for the extract() function has this warning:
WARNING Do not use extract() on untrusted data, like user input (e.g. $_GET, $_FILES).
The WordPress coding standards go farther and say don’t use that function at all.
No validation or sanitzation is done when bringing in the user input there, which is a big security risk and part of the issue with using extract(). If, for example, one of those inputs is then output without escaping, that would permit persistent cross-site scripting (XSS) to occur. That is exactly what occurs with the shortcode attribute “class” which is converted to the variable $class:
726 | return '<span class="oceanwp-breadcrumb'. $class .'">'. $breadcrumb->get_trail() .'</span>'; |
That wouldn’t be a vulnerability for WordPress users with the “unfiltered_html” capability as they are allowed to do the equivalent of XSS, but as the proof of concept below confirms, lower-level users without that capability can exploit this.
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
Creating a new post as a user with the Author role, which doesn’t have the unfiltered_html, with the following shortcode will cause an alert box with any available cookies to be shown when hovering over the plugin’s content on the page.
[oceanwp_breadcrumb class=' " onmouseover="alert(document.cookie);']