Remote Code Execution (RCE) Vulnerability in CX Easy Contact Form
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 a variant of one of those vulnerabilities, a remote code execution (RCE) vulnerability in a brand new plugin, CX Easy Contact Form.
We now are also running all the plugins used by our customers through the same system used for the proactive monitoring 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 exploitation of this vulnerability, even before we discovered the vulnerability, as part of its protection against zero-day vulnerabilities.
Remote Code Execution (RCE)
The plugin’s functionality is a contact form, which includes the ability to send a file with the message. That is only intended to be used to upload files with a limited variety of file extensions:
<input type="file" accept=".doc,.docx,.pdf,.jpg,.jpeg,.png,.JPEG" name="doc_upload" id="doc_upload"> |
The code for handling submissions, located in the file /cx-easy-contact-form.php, doesn’t include the same restriction on what file extensions can be processed:
220 221 222 223 224 | if(isset($_FILES['doc_upload']['tmp_name'])){ if(!empty($_FILES['doc_upload']['tmp_name'])){ $final_file_name = sanitize_file_name(basename($_FILES['doc_upload']['name'])); move_uploaded_file( $_FILES['doc_upload']['tmp_name'], WP_CONTENT_DIR.'/uploads/'.$final_file_name); $anexo = WP_CONTENT_DIR.'/uploads/'.$final_file_name; |
That code will save the uploaded file to a known location on the website.
Later code will delete the file after attempting to send an email of the contact form submission:
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | $send_email = wp_mail( $to, $subject, $body, $headers,$anexo); if($send_email){ $cxecf_email_succes_message = (isset($options['cxecf_email_succes_message']))?esc_html($options['cxecf_email_succes_message']):''; if(empty($cxecf_email_succes_message)){ $cxecf_email_succes_message = __( 'Email succesfully send!','cx-easy-contact-form'); } echo '<div class="falert falert-success" role="alert">'.esc_html($cxecf_email_succes_message).'</div>'; if($anexo){ unlink($anexo); } }else{ $cxecf_email_error_message = (isset($options['cxecf_email_error_message']))?esc_html($options['cxecf_email_error_message']):''; if(empty($cxecf_email_error_message)){ $cxecf_email_error_message = __( 'Failed to send Email!','cx-easy-contact-form'); } echo '<div class="falert falert-danger" role="alert">'.esc_html($cxecf_email_error_message).'</div>'; if($anexo){ unlink($anexo); } |
So the file will not remain on the website, but before it gets deleted an attacker could send a request for the file. So an attacker could upload a .php file and cause the code to run before the file is deleted, which would be remote code execution (RCE).
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.
After four years, the moderators have finally tacitly admitted they were behaving inappropriately and have made moves to fix the problems (though incompletely), so these full disclosures can be ended if they simply restore access to our accounts and plugins in the Plugin Directory. Hopefully that takes less than four years.
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 contact form can be added to a page with the [cxecf_contact_form] shortcode.