28 Apr

Reflected Cross-Site Scripting (XSS) Vulnerability in WP Statistics

A couple of days ago we started to look into a series of releases (12.0.2-12.0.5) of the plugin WP Statistics that were indicated to have fixed cross-site scripting (XSS) vulnerabilities. While there were a couple of advisories put out related to this, those didn’t include the details needed to confirm that vulnerabilities had existed and had been fixed. When we started testing things out to figure out exactly what was going on, we accidentally ran across yet another XSS vulnerability, this time a reflected XSS vulnerability.

While that is a minor vulnerability, it probably isn’t the best sign of the security of that plugin that we could stumble on to yet another vulnerability. Considering that this is a plugin with 300,000+ active installs according to wordpress.org, it also isn’t a good sign as to the security of WordPress plugins in general.

The issue started in the file /includes/log/page-statistics.php where the value of the GET input “page-uri” is set to the variable $pageuri without being sanitized:

7
if( array_key_exists( 'page-uri', $_GET ) ) { $pageuri = $_GET['page-uri']; } else { $pageuri = null; }

That variable is then added to the variable $urlfields:

20
if( $pageuri ) { $urlfields .= "&page-uri={$pageuri}"; }

And the second variable is passed to the function wp_statistics_date_range_selector():

29
wp_statistics_date_range_selector( WP_STATISTICS_PAGES_PAGE, $daysToDisplay, null, null, $urlfields );

From there in the file /includes/functions/functions.php the value was output unescaped on line 972:

echo 'href="?page=' . $page . '&hitdays=' . $range[$i] . $extrafields . '">' . $desc[$i] . '';

And on line 988:

echo '<input type="hidden" name="' . $key . '" value="' . $value . '">';

In version 12.0.6 both of those instances where it is output now pass the value through the escaping function esc_url():

echo 'href="?page=' . $page . '&hitdays=' . $range[$i] . esc_url($extrafields) . '">' . $desc[$i] . '</a></li>';
echo '<input type="hidden" name="' . $key . '" value="' . esc_url($value) . '">';

Proof of Concept

The following proof of concept will cause any available cookies to be shown in alert box. Major web browsers other than Firefox provide XSS filtering, so this proof of concept will not work in those web browsers.

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

http://[path to WordPress]/wp-admin/admin.php?page=wps_pages_page&page-uri=%3F%22%3E%3Cscript%3Ealert%28document.cookie%29%3B%3C%2Fscript%3E

Timeline

  • April 26, 2017 – Developer notified.
  • April 26, 2017 – Developer responds.
  • April 28, 2017 – Version 12.0.6 released, which fixes vulnerabilities.

Concerned About The Security of The Plugins You Use?

When you are a paying customer of our service (you can currently try the service free for the first month), you get to suggest/vote on what plugins we will do security reviews of.

Leave a Reply

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