16 May 2019

This Persistent Cross-Site Scripting (XSS) Vulnerability Seems Likely to Be What Hackers Would be Interested in FB Messenger Live Chat For

As part of making sure our customers are getting the best information on vulnerabilities in WordPress plugins they may be using we monitor for hackers probing for usage of plugins on our website and then try to figure out what the hackers might be looking to exploit. Today we have had what look to be hackers probing for usage of five plugins. Two of those have recently had vulnerabilities disclosed that involve persistent cross-site scripting (XSS). The other three do not appear to have had vulnerabilities recently disclosed, but have persistent XSS vulnerabilities as well. One of those plugins is FB Messenger Live Chat (Live Chat with Facebook Messenger), which has 30,000+ installs according to wordpress.org. In looking over the plugin we found that it contains a persistent cross-site scripting (XSS) vulnerability, which is a type of vulnerability hackers have been exploiting widely recently.

For no good reason the plugins allows even those not logged in to WordPress to change its settings, as it registers it so the function that handles that, update_zb_fbc_code(), is accessible through WordPress’ AJAX functionality to those logged in to WordPress as well as those not logged in:

154
155
add_action("wp_ajax_update_zb_fbc_code", "update_zb_fbc_code");
add_action("wp_ajax_nopriv_update_zb_fbc_code", "update_zb_fbc_code");

That function doesn’t include a capabilities check or a check to prevent cross-site request forgery (CSRF) before allowing settings to be changed:

157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
function update_zb_fbc_code(){
	header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Credentials: true');
	$domain = addslashes($_REQUEST['domain']);
	$public_key = addslashes($_REQUEST['access']);
	$id = intval($_REQUEST['customer']);
	$zbEmail = addslashes($_REQUEST['email']);
	if(!isset($domain) || empty($domain)){
		header("Location: ".admin_url()."admin.php?page=zb_fbc");
	}else{
		update_option( 'ztb_domainid', $domain );
		update_option( 'ztb_access_key', $public_key );
		update_option( 'ztb_id', $id );
		update_option( 'ztb_email', $zbEmail );
		update_option( 'ztb_status_disconnect', 2 );
		wp_send_json( array(
			'error' => false,
			'message' => 'Update Zotabox embedded code successful !' 
			)
		);
	}
}

It does some limited sanitization and validation on user input being set to the settings, but the sanitization uses addslashes(), which isn’t sufficient. The domain setting set there is then output on frontend pages without being escaped, permitting persistent cross-site scripting (XSS) to occur.

The plugin registers insert_zb_fbc_code() to be run when WordPress pages are loaded:

151
add_action( 'wp_head', 'insert_zb_fbc_code' );

That function will then pass the value of the domain setting to the function print_zb_fbc_code() and the output the result of that if a frontend page is being loaded:

139
140
141
142
143
144
145
146
147
148
149
function insert_zb_fbc_code(){
	if(!is_admin()){
		$domain = get_option( 'ztb_domainid', '' );
		$ztb_source = get_option('ztb_source','');
		$ztb_status_disconnect = get_option('ztb_status_disconnect','');
		$connected = 2;
		if(!empty($domain) && strlen($domain) > 0 && $ztb_status_disconnect == $connected){
			print_r(html_entity_decode(print_zb_fbc_code($domain)));
		}
	}
}

The function print_zb_fbc_code() doesn’t escape the domain value when including it in what is returned:

180
181
182
183
184
185
186
187
188
189
190
191
function print_zb_fbc_code($domainSecureID = "", $isHtml = false) {
 
	$ds1 = substr($domainSecureID, 0, 1);
	$ds2 = substr($domainSecureID, 1, 1);
	$baseUrl = '//static.zotabox.com';
	$code = <<<STRING
<script type="text/javascript">
(function(d,s,id){var z=d.createElement(s);z.type="text/javascript";z.id=id;z.async=true;z.src="{$baseUrl}/{$ds1}/{$ds2}/{$domainSecureID}/widgets.js";var sz=d.getElementsByTagName(s)[0];sz.parentNode.insertBefore(z,sz)}(document,"script","zb-embed-code"));
</script>
STRING;
	return $code;
}

Due to the moderators of the WordPress Support Forum’s continued inappropriate behavior we are full disclosing vulnerabilities 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. 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:

Proof of Concept

The following proof concept will cause an alert box with the number “1” to be shown on frontend pages of the website.

Make sure to replace “[path to WordPress]” with the location of WordPress.

http://l[path to WordPress]/wp-admin/admin-ajax.php?action=update_zb_fbc_code&domain=</script><script>alert(1);</script>

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.


Concerned About The Security of the Plugins You Use?

When you are a paying customer of our service, you can suggest/vote for the WordPress plugins you use to receive a security review from us. You can start using the service for free when you sign up now. We also offer security reviews of WordPress plugins as a separate service.

5 thoughts on “This Persistent Cross-Site Scripting (XSS) Vulnerability Seems Likely to Be What Hackers Would be Interested in FB Messenger Live Chat For

  1. The following message appear on the top of my website and redirects people to other pages: /widgets.js”;var sz=d.getElementsByTagName(s)[0];sz.parentNode.insertBefore(z,sz)}(document,”script”,”zb-embed-code”));

    • If you are using this plugin then that sounds like it would be what would occur if the vulnerability is exploited.

  2. My website was hit by this attack. I didn’t realise this plugin was installed, so disabling it seems to have resolved the issue for now. Thanks for the detailed write-up.

  3. Hi, Zotabox fixed this issue the same day that WordPress notified us. We recommend all users update to our latest version to avoid unwanted script load on their site. If your website is affected we recommend de-activating then activating our plugin after updating to fix this issue. Please refresh your website cache after activating again. We are sorry for any inconvenience caused.

    • By WordPress notified you, we are guessing they didn’t tell you they did that after blocking our direct notification to you.

      Based on they type of vulnerability here, the hackers may have caused additional changes to to the websites once they exploited the vulnerability, so the actions you are mentioning may not be enough to fully clear out what has happened.

Leave a Reply

Your email address will not be published.