Authenticated Open Redirect Vulnerability in Paid Memberships Pro
One ongoing indication of the poor security of WordPress plugins is how often our Plugin Security Checker, which is an automated tool for identifying some possible security issues with plugins, is picking up vulnerabilities in fairly popular plugins. We would not describe the tool as being advanced by any means, so that being true is not a great indication of the handling of plugins’ security. In looking over some of the recent results for plugins in the Plugin Directory that were checked through that to see if could further improve its results we found that the plugin Paid Memberships Pro, which has 80,000+ active installations according to wordpress.org, contains an authenticated open redirect vulnerability.
That is a type of vulnerability that isn’t really a concern in terms of being exploited on the average website, but it is something that looks like it could have easily been avoided. You can check the plugins you use to see if they are possibly impacted by a similar issue or a number of other issues through the tool for free.
The plugin registers the function pmpro_redirect_to_logged_in() to run when redirects can occur:
168 | add_action("template_redirect", "pmpro_redirect_to_logged_in", 5); |
When accessing WordPress’ login page when logged in to WordPress that function will cause the request to redirect to the URL specified by the GET or POST input “redirect_to”:
160 161 162 163 164 165 166 167 | function pmpro_redirect_to_logged_in() { if((pmpro_is_login_page() || is_page("login")) && !empty($_REQUEST['redirect_to']) && is_user_logged_in() && (empty($_REQUEST['action']) || $_REQUEST['action'] == 'login') && empty($_REQUEST['reauth'])) { wp_redirect($_REQUEST['redirect_to']); exit; } } |
That redirect is done using the function wp_redirect(), which as noted in its documentation is insecure in just this type of situation:
wp_redirect() does not validate that the $location is a reference to the current host. This means that this function is vulnerable to open redirects if you pass it a $location supplied by the user. For this reason, it is best practice to always use wp_safe_redirect() instead, since it will use wp_validate_redirect() to ensure that the $location refers to the current host. Only use wp_redirect() when you are specifically trying to redirect to another site, and then you can hard-code the URL.
It looks like wp_safe_redirect() would be the appropriate function to use in this case.
Due to the moderators of the WordPress Support Forum’s continued inappropriate behavior we are full disclosing vulnerabilities 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. 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 redirect you to our homepage, when logged in to WordPress.
Make sure to replace “[path to WordPress]” with the location of WordPress.
http://[path to WordPress]/wp-login.php?redirect_to=https://www.pluginvulnerabilities.com
Thank you for bringing this to our attention.
Version 2.0.6 was just pushed out with the security fix you suggested and a couple other spots were wp_safe_redirect was more appropriate.
Version 2.0.7 was also pushed out with other bug fixes and enhancements that have been in the queue for release.
Users should update to 2.0.7, or if they just want the security update, they can update to 2.0.6.
https://wordpress.org/plugins/paid-memberships-pro/