Authenticated Persistent Cross-Site Scripting (XSS) Vulnerability in Ivory Search
Yesterday, the WordPress plugin Ivory Search was closed on WordPress Plugin Directory. Due to that being one of the 1,000 most popular plugins in that directory (it has 70,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 be warning customers of our service about if they are using the plugin. We found the plugin contains code that looks to not be properly secured and confirmed that it contains at least a minor vulnerability. We would recommend not using the plugin unless it has received a thorough security review and all the issues are addressed.
We tested and confirmed that our new firewall plugin for WordPress protected against the proof of concept below, even before we discovered the vulnerability, as part of its protection against zero-day vulnerabilities.
Authenticated Persistent Cross-Site Scripting (XSS)
While looking into one portion of the insecure code, we found the plugin has a shortcode. We have often found that those are not properly secured and a quick test confirmed that was the case with the plugin, leading to an authenticated persistent cross-site scripting vulnerability.
The plugin registers the shortcode to call the function search_form_shortcode():
207 | add_shortcode( 'ivory-search', array( $is_loader, 'search_form_shortcode' ) ); |
That function, which is located in the file ~/Sites/wordpress/wp-content/plugins/add-search-to-menu/includes/class-is.php, restricts the value of the shortcode attribute “id” when setting it to the value of $id, but then sends the original value to the function form_html():
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 | function search_form_shortcode( $atts ) { if ( is_feed() ) { return '[ivory-search]'; } if ( isset( $this->opt['disable'] ) ) { return; } $atts = shortcode_atts( array( 'id' => 0, 'title' => '', ), $atts, 'ivory-search' ); $id = (int) $atts['id']; $search_form = IS_Search_Form::get_instance( $id ); if ( ! $search_form ) { return '[ivory-search 404 "The search form '.$id.' does not exist"]'; } $form = $search_form->form_html( $atts ); |
The function form_html(), which is located in the file /includes/class-is-search-form.php, outputs the value without escaping in multiple locations, including in code that runs in the plugin’s Enable AJAX Search option is enabled:
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | if ( isset( $_ajax['enable_ajax'] ) ) { $is_ajax_search = 'is-ajax-search'; $form_style = ( '' == $form_style ) ? 'is-form-style-3' : $form_style; // Enqueue scripts. wp_enqueue_script( 'ivory-ajax-search-scripts' ); if ( ! ivory_search_is_json_request() && isset( $_settings['highlight_terms'] ) ) { wp_enqueue_script( 'is-highlight' ); if ( isset( $_settings['highlight_color'] ) && ! empty( $_settings['highlight_color'] ) && ! is_search() ) { echo '<style type="text/css" media="screen">'; echo '#is-ajax-search-result-' . $args['id'].' .is-highlight { background-color: '.$_settings['highlight_color'].' !important;}'; echo '#is-ajax-search-result-' . $args['id'].' .meta .is-highlight { background-color: transparent !important;}'; echo '</style>'; } } $min_no_for_search = isset( $_ajax['min_no_for_search'] ) ? $_ajax['min_no_for_search'] : '1'; $result_box_max_height = isset( $_ajax['result_box_max_height'] ) ? $_ajax['result_box_max_height'] : '400'; // Add data AJAX attributes. $data_attrs = 'data-min-no-for-search="'.esc_attr( $min_no_for_search ).'"'; $data_attrs .= ' data-result-box-max-height="'.$result_box_max_height.'"'; $data_attrs .= ' data-form-id="'.$args['id'].'"'; } |
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 when the Enable AJAX Search option is enabled in the plugin’s settings.
Replace “[search ID]” with the ID of a search form.
[ivory-search id='[search id]" onmouseover="alert(document.cookie);' title="Default Search Form"]
I am a plugin developer and I want to notify you here that the issue is fixed in plugin version 4.8
If this is in regards to this situation, we would recommend you suggest people use a more reliable source for information on vulnerabilities in WordPress plugins, as we already notified our customers it was fixed in November.