17 Jul

Authenticated Persistent Cross-Site Scripting (XSS) Vulnerability in HubSpot All-In-One Marketing – Forms, Popups, Live Chat

Yesterday a new version the WordPress plugin HubSpot All-In-One Marketing – Forms, Popups, Live Chat, which has 80,000+ installs, came on to our radar as there were a couple of seeming security related entries in the changelog for that version:

  • Fix comment escaping
  • Sanitize inputs

As part of collecting data for our service, so that we can inform our customers if plugins they use contain vulnerabilities we started looking into the changes. The very first change made was to change a line of code from this:

30
<?php echo $text; ?

To this:

30
<?php echo $text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>

The commented text is for whitelisting code for the WordPress Coding Standards for PHP_CodeSniffer (WPCS), which is a tool to “ensure[s] code quality and adherence to coding conventions, especially the official WordPress Coding Standards.” We have sometimes seen people treating that tool as providing an assessment of security beyond what it is intended and able to.

However that tool was being used here it turns out that the plugin has a fairly serious vulnerability due to failing to do security basics. The failures would have been caught by the type of manual security review of WordPress plugins we do due, during multiple of the checks done during our process.

The problems possibly start with yet another instance of the problems caused by confusion over the is_admin() function, which was originally warned about before it made it in to WordPress 8 years ago. That function tells you if an admin page is being requested, not if an Administrator is making a request. That will also return true if making an AJAX request to WordPress, so this code in the plugin makes the function leadin_registration_ajax() accessible to anyone logged in to WordPress:

6
7
8
if ( is_admin() ) {
	add_action( 'wp_ajax_leadin_registration_ajax', 'leadin_registration_ajax' );
}

That function, which is located in the file /inc/leadin-registration.php, will save a number of settings for the plugin:

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function leadin_registration_ajax() {
	delete_option( 'leadin_hapikey' );
	$existing_portal_id = get_option( 'leadin_portalId' );
 
	if ( ! empty( $existing_portal_id ) ) {
		wp_die( '{"error": "Registration is already complete for this portal"}', '', 400 );
	}
 
	$request_body = file_get_contents( 'php://input' );
	$data         = json_decode( $request_body, true );
 
	$new_portal_id = $data['portalId'];
 
	if ( empty( $new_portal_id ) ) {
		$error_body = array(
			'error'   => 'Registration missing required fields',
			'request' => $request_body,
		);
 
		wp_die( json_encode( $error_body ), '', 400 );
	}
 
	$user_id               = $data['userId'];
	$access_token          = $data['accessToken'];
	$refresh_token         = $data['refreshToken'];
	$connection_time_in_ms = $data['connectionTimeInMs'];
 
	add_option( 'leadin_portalId', $new_portal_id );
	add_option( 'leadin_userId', $user_id );
	add_option( 'leadin_accessToken', $access_token );
	add_option( 'leadin_refreshToken', $refresh_token );
	add_option( 'leadin_connectionTimeInMs', $connection_time_in_ms );
 
	wp_die( '{"message": "Success!"}' );
}

That doesn’t contain a security check to limit who can access it, a check to protect against cross-site request forgery (CSRF), and doesn’t sanitize or validate the input being saved.

As the proof of concept below shows, it can cause malicious JavaScript to be output on admin pages of the website, so there is an authenticated persistent cross-site scripting (XSS) vulnerability in the plugin. That could also be exploited through a CSRF.

There is limitation to that, you can’t update those settings if the settings have already been set since if the setting ‘leadin_portalId” exists the rest of the code in the function doesn’t run.

That turns out to not be an issue though because of another similarly improperly secured AJAX accessible function, leadin_disconnect_ajax(), which is registered in the same way:

6
7
8
if ( is_admin() ) {
	add_action( 'wp_ajax_leadin_disconnect_ajax', 'leadin_disconnect_ajax' );
}

That function, which is located in the file /inc/leadin-disconnect.php, will delete the plugin’s settings:

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function leadin_disconnect_ajax() {
	if ( get_option( 'leadin_portalId' ) ) {
		delete_option( 'leadin_portalId' );
		delete_option( 'leadin_slumber_mode' );
		delete_option( 'leadin_hapikey' );
 
		delete_option( 'leadin_accessToken' );
		delete_option( 'leadin_refreshToken' );
		delete_option( 'leadin_oauth_mode' );
		delete_option( 'leadin_userId' );
		delete_option( 'leadin_connectionTimeInMs' );
 
		wp_die( '{"message": "Success!"}' );
	} else {
		wp_die( '{"error": "No leadin_portalId found, cannot disconnect."}', '', 400 );
	}
}

Full Disclosure

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:

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

When logged in to WordPress send a request to /wp-admin/admin-ajax.php?action=leadin_registration_ajax with this as the body:

{"portalId":"\"><script>alert(document.cookie);<\/script>"}

After that, when logged in to WordPress as an Administrator an alert box with any available cookies will be shown.


Concerned About The Security of the Plugins You Use?

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

Leave a Reply

Your email address will not be published. Required fields are marked *