10 Jun

Recently Closed WordPress Plugin with 30,000+ Installs Contains Persistent XSS Vulnerability

The plugin SEO Redirection was closed on the WordPress Plugin Directory yesterday. That is one of the 1,000 most popular plugins with 30,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 warn users of the plugin that also use our service, we found it contained multiple security issues, what looked to be the most serious issue that we found in just a quick check is a persistent cross-site scripting (XSS) vulnerability. That is something that hackers might be interested in exploiting.

We would recommend not using the plugin until it has had its security thoroughly reviewed, and the issues identified, fixed, due to how insecure we found it to be.

The plugin contains functionality that logs requests for URLs that don’t exist on the website. That involves recording various user input, which needs to be properly processed through some combination of sanitization, validation, and escaping to avoid security issues. As the proof of concept below shows, that isn’t true for the URL being requested. What we found a bit odd while checking on that, is that this could be abused in a way that you normally wouldn’t be able to.

The relevant code starts in the function WPSR_redirect(), which is run when a WordPress page is accessed:

add_action('wp', 'WPSR_redirect', 1);

That function, which is located in the file /seo-redirection.php, gets the value of the URL from other functions in the plugin and sets it to the value of the variable $permalink:

function WPSR_redirect()
    global $wpdb, $post, $table_prefix, $util;
    if ($util->get_option_value('plugin_status') != '0') { // if not disabled
        // if disable for admin and the user is admin
        if (current_user_can('manage_options') == 1 && $util->get_option_value('plugin_status') == 2) {
            // nothing
        } else {
            $table_name = $table_prefix . 'WP_SEO_Redirection';
            $permalink = urldecode($util->get_current_relative_url());

The use of the function urldecode() makes the situation worse as it allows passing JavaScript code into the URL more easily, since if you request a URL with JavaScript code in it in a web browser, it would be encoded and therefore wouldn’t be functional. The value isn’t sanitized or validated in any code that runs up to that point.

The value is the passed to function WPSR_log_404_redirection:


That function doesn’t do those things either:

function WPSR_log_404_redirection($link)
    global $wpdb, $table_prefix, $util;
    $table_name = $table_prefix . 'WP_SEO_404_links';
    $referrer = $util->get_ref();
    $ip = $util->get_visitor_IP();
    $country = "";//$util->get_visitor_country();
    $os = $util->get_visitor_OS();
    $browser = $util->get_visitor_Browser();
    if ($os != 'Unknown' || $browser != 'Unknown') {
        $wpdb->query($wpdb->prepare(" insert IGNORE into $table_name(ctime,link,referrer,ip,country,os,browser) values(NOW(),%s,%s,%s,%s,%s,%s) ", $link, $referrer, $ip, $country, $os, $browser));

As the proof of concept below show, the value is not escaped when output on an admin page of the plugin.

WordPress Causes Full Disclosure

Because of the moderators of the WordPress Support Forum’s continued inappropriate behavior we changed from reasonably disclosing to full disclosing vulnerabilities for plugins in the WordPress Plugin Directory 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. (For plugins that are also in the ClassicPress Plugin Directory, we will follow our reasonable disclosure policy.) 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 of concept will cause an alert box with any available cookies to be shown on the page /wp-admin/options-general.php?page=seo-redirection.php&tab=404.

Replace “[path to WordPress]” with the location of WordPress.

http://[path to WordPress]/test"><script>alert(document.cookie);</script>

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.