AOH :: HP Unsorted G :: BU-1100.HTM

Google Analytics plugin for Wordpress - XSS Vulnerability
Google Analytics plugin for Wordpress - XSS Vulnerability
Google Analytics plugin for Wordpress - XSS Vulnerability

Yoast GA Plugin for WP - Cross Site Scripting Vulnerability

Version Affected: 3.2.4 (newest)

Info: The Google Analytics for WordPress plugin automatically tracks and
segments all outbound links from within posts, comment author links, links
within comments, blogroll links and downloads. It also allows you to track 
AdSense clicks, add extra search engines, track image search queries and it
will even work together with Urchin.

Credits: InterN0T

External Links: 

-:: The Advisory ::-
On line 353 in googleanalytics.php the following vulnerable code was identified:
 * If this is a 404 page, track the 404 and prevent all other stuff as it's not needed.
if ( is_404() ) {
echo "\t\t".'pageTracker._trackPageview("/404.html?page=" + document.location.pathname + + "&from=" + document.referrer);'."\n";
echo "\t".'} catch(err) {}'."\n";
echo ''."\n";					=09
} else if ($wp_query->is_search && $wp_query->found_posts == 0) {
echo "\t\t".'pageTracker._trackPageview("'.get_bloginfo('url').'/?s=no-results: '.$wp_query->query_vars['s'].'&cat=no-results");'."\n";
echo "\t".'} catch(err) {}'."\n";
echo ''."\n";

In order to trigger this bug, a 404 (Not Found) message must be the response when supplying the XSS code into the search-form.

One can either end the script tag or use javascript in order to abuse this issue.

Proof of Concept's:
A. alert(0) 
B. ");alert(0);document.write("

A. hxxp://localhost/wp/?s=
B. hxxp://localhost/wp/?s=");alert(0);document.write("

If magic_quotes is enabled inside php.ini, Proof of Concept (B) wont work.

-:: Solution ::-
The following patch was supplied to the vendor:

On line 361 in googleanalytics.php the following piece of code is vulnerable to Cross Site Scripting:
echo "\t\t".'pageTracker._trackPageview("'.get_bloginfo('url').'/?s=no-results: '.$wp_query->query_vars['s'].'&cat=no-results");'."\n";

In order to prevent this, One will have to use f.ex. htmlentities or rawurlencode to secure it:
echo "\t\t".'pageTracker._trackPageview("'.get_bloginfo('url').'/?s=no-results: '.rawurlencode($wp_query->query_vars['s']).'&cat=no-results");'."\n";

The reason why we thought rawurlencode might be suitable is because htmlentities in a tracking URL might break the Google Analytics Tracking.

Disclosure Information:
- Vulnerability found 3rd December
- Patch was made available 4th December
- Disclosed on InterN0T 4th December
- Vendor and Buqtraq (SecurityFocus) contacted the 4th December

All of the best,

The entire AOH site is optimized to look best in Firefox® 3 on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2015 AOH
We do not send spam. If you have received spam bearing an email address, please forward it with full headers to