11 Sep

What Security Review? Brand New WordPress Plugin Contains CSRF/Arbitrary File Deletion Vulnerability

Brand new WordPress plugins are supposed to go through a security review before being allowed in the Plugin Directory. Either those reviews are not happening or they are failing to catch things that should have been caught. Take the plugin Prevent Files / Folders Access, which we came across due our proactive monitoring of changes made to plugins in the Plugin Directory to try to catch serious vulnerabilities flagging that it contains a cross-site request forgery (CSRF)/arbitrary file deletion vulnerability.

We have long offered to provide the team running the Plugin Directory help to have a capability similar to that monitoring. Running the plugin through our Plugin Security Checker would have warned about that as well. We have also long offered the team running the Plugin Directory free access to the advanced mode of that tool for free. We haven’t heard any interest from that team to either of those offers.

The plugin registers its admin page to be accessible to Administrators:

$page = add_menu_page( 'miniOrange Prevent Files / Folders Access' . __( 'Configure Prevent Files / Folders Access', 'mo_media_restrict' ), 'miniOrange Prevent Files /	 Folders Access', 'administrator', 'mo_media_restrict', array( $this, 'mo_media_restrict_options' ), plugin_dir_url(__FILE__) . '../public/images/miniorange.png' );

As far as we are aware it is intended that you would specify a capability, not a role, when defining who can access that, which maybe a review should have caught. In any case accessing that page cause the function mo_media_restrict_options() to run and that in turn causing the function mo_media_restrict_page() to run:

function  mo_media_restrict_options () {
	$plugin_admin = new Media_Restriction_Admin( $this->get_plugin_name(), $this->get_version() );

In that function, which is located in the file /admin/class-media-restriction-admin.php, if the POST input “option” doesn’t exist and the GET input “deletefile” does exist then the value of the latter of those will be passed to the unlink() function, which deletes a file:

public function mo_media_restrict_page() {
	else if(isset($_GET['deletefile'])){
		$upload_dir = wp_upload_dir();
		if($upload_dir && isset($upload_dir['basedir'])){
			$base_upload_dir = $upload_dir['basedir'];
			$protectedfiles = $base_upload_dir.DIRECTORY_SEPARATOR."protectedfiles";
			if (file_exists($protectedfiles.DIRECTORY_SEPARATOR.$_GET['deletefile']))

Through directory traversal any file on the website can be deleted.

There should be security checks to limit what WordPress users can access that functionality, prevent cross-site request forgery (CSRF), and restrict directory traversal from being possible.

Without protection against CSRF it is possible for an attacker to cause an Administrator to delete a file or files without intending it.

Full Disclosure

Due to the moderators of the WordPress Support Forum’s continued inappropriate behavior we are full disclosing vulnerabilities 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. 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).

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 the file test.txt in the root directory of the website, when logged in to WordPress as an Administrator.

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

http://[path to WordPress]/wp-admin/admin.php?page=mo_media_restrict&deletefile=../../../test.txt

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.