FL3R User Agent Comments – Unauthenticated Injection into Posts and Dashboard

The plugin FL3R User Agent Comments is vulnerable to a stored XSS attack that allows for arbitrary Javascript execution in the context of the admin dashboard, as well as injection into any page which displays comments.

The plugin generates small icon images that represent the HTTP User Agent associated with posted comments. By default, the plugin will create and display icons next to each comment in the comments admin page, the dashboard, and the public-facing post on which the comment was left, using the following pattern:

The included file include/browser.php defines a PHP class that is used to construct an object representing several defining characteristics of an HTTP User Agent. The object contains several fields, including Name, Version, Platform, and Pver (platform version). User agent data is loaded from the wp-comments DB table; WordPress’ comment system does not perform any transformation of the User Agent header beyond generic SQL input sanitation, though it does limit stored values to 254 characters.

Object values are set using basic string parsing (stristr, stripos) based on the contents of the stored User Agent data, using this matching to build object keys based on a limited set of values. There is even what appears to be a token attempt at sanitization for values that have not yet been matched:

However, in some cases, the constructor uses a combination of explode and stripos to build several object values based on the raw contents of the User Agent header:

Here$agent is the value of the comment_agent in the comment database record. This means its trivial to create a browser object with arbitrary $bd['platform'] and $bd['pver'] values, which are then assigned to the Browser object’s Platform and Pver keys, respectively. From here, those values will be interpolated directly into the comments admin page, dashboard, and post output.

Exploiting this is as simple as adding comment to any existing WordPress post with a malicious User Agent header. Javascript and HTML tags can be inserted in arbitrary fashion; exploiting the parsing of a Fedora UA is shown below:

A recent update was pushed that appears to resolve these issues.

Leave a Reply

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