Aerosol Posted March 20, 2015 Report Posted March 20, 2015 OVERVIEW==========Google Analytics by Yoast is a WordPress plug-in for monitoringwebsite traffic. With approximately seven million downloads it’s oneof the most popular WordPress plug-ins.A security vulnerability in the plug-in allows an unauthenticatedattacker to store arbitrary HTML, including JavaScript, in theWordPress administrator’s Dashboard on the target system. TheJavaScript will be triggered when an administrator views the plug-in’ssettings panel. No further user interaction is required.Typically this can be used for arbitrary server-side code executionvia the plugin or theme editors. Alternatively the attacker couldchange the administrator’s password, create new administratoraccounts, or do whatever else the currently logged-in administratorcan do on the target site.DETAILS=======The impact is a combination of two underlying problems. Firstly,missing access control allows an unauthenticated user to modify someof the settings associated with the plug-in. It’s possible overwritethe existing OAuth2 credentials which the plug-in uses for retrievingdata from Google Analytics, and thereby connect the plug-in with theattacker’s own Google Analytics account.Secondly, the plug-in renders an HTML dropdown menu based on the datadownloaded from Google Analytics. This data is not sanitized orHTML-escaped. If the said attacker enters HTML code such as <script>tags in the properties in their Google Analytics account settings, itwill appear in the WordPress administrative Dashboard of the targetedsystem and get executed whenever someone views the settings.PROOF OF CONCEPT==================The following HTML snippet could be used to hijack the GoogleAnalytics account of a website running a vulnerable version of theplug-in:<a href="http://YOUR.BLOG/wp-admin/admin-post.php?reauth=1">reauth</a><br><br><form method=POST action="http://YOUR.BLOG/wp-admin/admin-post.php"><input type=text size=100 name="google_auth_code"><input type=submit></form>First, the attacker would click the reauth link. The action doesn'trequire any kind of authentication. It will reset some of the pluginsettings and redirect the attacker to a google.com OAuth dialog, wherethey'd get an authentication code.Next the attacker would copy-paste the code in the above form andsubmit. This would update the code in the plugin settings - againwithout requiring authentication. The plugin would now retrieve itsdata from the attacker's Google Analytics account.The actual payload script would be entered at the attacker's ownGoogle Analytics account settings athttps://www.google.com/analytics/web/?hl=en#management/Settings/An example of a property name: test"><script>alert('stored XSS')</script>This would fire an alert box whenever an administrator views theAnalytics settings page in the Dashboard of the target WordPress site.A real-world attack would probably use a src attribute to load a moresophisticated script from an external site. It could make chained ajaxcalls to load and submit administrative forms, including those of theplugin editor to write server-side PHP code, and finally execute it.SOLUTION=========Yoast was notified on March 18, 2015. A new version of the plug-in(5.3.3) was released the next day.CREDITS========The vulnerability was found by Jouko Pynnönen of Klikki Oy, Finland.An up-to-date version of this document is available athttp://klikki.fi/adv/yoast_analytics.html-- Jouko Pynnönen <jouko@iki.fi>Klikki Oy - http://klikki.fi - @klikkioySource Quote