Web Flaws and Vulnerabilities

Arbitrary File Download Vulnerability in WP Hide Security Enhancer

Blog Web Flaws and Vulnerabilities Arbitrary File Download Vulnerability in WP Hide Security Enhancer

WP Hide Security Enhancer is a security plugin used to hide your WordPress installation. It has been developed by NSP Code. On 15th February 2017, the plugin author has been warned, and the fixes were done pretty quickly, thanks to him.

Critical Flaw

WP Hide Security Enhancer version or less is victim of an Arbitrary File Download vulnerability. This allows any visitor to download any file in our installation. As you already guessed, it’s a critical flaw.

How does it work?

Sadly it’s very simple to exploit it:

In the /router/ folder you can find a file-process.php file.



$action = isset($_GET['action']) ? $_GET['action'] : '';
$file_path = isset($_GET['file_path']) ? $_GET['file_path'] : '';

if(empty($action) || empty($file_path))

//append doc root to path
$file_path = $_SERVER["DOCUMENT_ROOT"] . $file_path;

//check if file exists
if (!file_exists($file_path))

$WPH_FileProcess = new WPH_FileProcess();

$WPH_FileProcess->action = $action;
$WPH_FileProcess->file_path = $file_path;


class WPH_FileProcess
var $action;
var $file_path;

function __construct()

function __destruct()
$out = ob_get_contents();

echo $out;

function run()
case 'style-clean' :


function style_clean()
//output headers
$expires_offset = 31536000;

header('Content-Type: text/css; charset=UTF-8');
header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');
header("Cache-Control: public, max-age=$expires_offset");
header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($this->file_path)).' GMT', true);

$handle = fopen($this->file_path, "r");
$file_data = fread($handle, filesize($this->file_path));

$file_data = preg_replace('!/\*.*?\*/!s', '', $file_data);
$file_data = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $file_data);

echo $file_data;



This file is not included in WordPress, so, there is no way that a WordPress Security plugin can catch that. You need a Web Application Firewall to do it.

But do what? All an attacker need is 2 parameters in the URL as requested in line 8:


Now, line 15 excepts an existing file. And an attacker knows an existing AND interesting file on your installation, which is wp-config.php.


Now, line 47 excepts an action named style-clean as simple as it is.


Here we go, this URL will be used by the attacker to display on his screen the file content.

My local demo wp-config.php file

Am I Protected?

You may already applied some script to protect your wp-config.php file. I’m sorry to tell you that, it does not work like that.


You may read that you can add some rules in your .htaccess file to protect it, rules like that:

<files wp-config.php>
order allow,deny
deny from all
Don't do that.

This does NOT protect you from this vulnerability. Why? Just because this protection only forbid direct access to the file from a browser, but not from a PHP script.

Folded Up

You may also read that you can protect you wp-config.php file by raising it in the file tree, so it’s not accessible anymore from your front-end. Yes, that’s true, but that’s all. A PHP script still can access to it:


How To Stay Safe With That Kind Of Flaw?

This kind of vulnerability happens a lot, giving access to thewp-config.php file is not cool, if you remember in 2014 the plugin revslider had the exact same issue.

You have to block some words in your URLs, because neither WordPress, nor you, nor a user, nor a client need to use this filename in a URL.

If you’re already using SecuPress Pro, you’re already protected fro that kind of attacks.