How the White-Box hacking works: webERP Local File Inclusion

In the previous post we described a couple of inoERP bugs and made a conclusion that inoERP software is too buggy for everyday usage. So we tried to find a better open-source alternative, and possibly save 600 dollars per user per month on Oracle Financials for somebody. Fortunately, we found that webERP still releases updates and has GNU General Public License (GPL) v2, so we decided to check it for easily reachable vulnerabilities.

Bug discovery

To discover the bug, we used “grep” binary to find each call to “include” or “require” function that also operates with any variables, and then reviewed the results manually.

 egrep '(include|require)(\ |\()(.*)(\$)' /var/www/html -ri

We had a look on webERP 4.15 and webERP 4.15.1.

WebERP v4.15 – Unauthenticated Local File Inclusion

In webERP 4.15, the code lines 22-25 of “ManualContents.php” file allow user to specify “Language” parameter. This leads to Local File Inclusion, at least in line 59. Also note line 32.

$Title = _('webERP Manual');
// Set the language to show the manual:
$Language = $_SESSION['Language'];
if(isset($_GET['Language'])) {// Set an other language for manual.
        $Language = $_GET['Language'];
// Set the Cascading Style Sheet for the manual:
$ManualStyle = 'locale/' . $Language . '/Manual/style/manual.css';
if(!file_exists($ManualStyle)) {// If locale ccs not exist, use doc/Manual/style/manual.css. Each language can have its own css.
        $ManualStyle = 'doc/Manual/style/manual.css';
// Set the the outline of the webERP manual:
$ManualOutline = 'locale/' . $Language . '/Manual/ManualOutline.php';
if(!file_exists($ManualOutline)) {// If locale outline not exist, use doc/Manual/ManualOutline.php. Each language can have its own outline.
        $ManualOutline = 'doc/Manual/ManualOutline.php';


// Output the header part:
$ManualHeader = 'locale/' . $Language . '/Manual/ManualHeader.html';
if(file_exists($ManualHeader)) {// Use locale ManualHeader.html if exists. Each language can have its own page header.
} else {// Default page header:
        echo '<!DOCTYPE html>
          <title>', $Title, '</title>
          <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
          <link rel="stylesheet" type="text/css" href="', $ManualStyle, '" />
        <body lang="', str_replace('_', '-', substr($Language, 0, 5)), '">
                <div id="pagetitle">', $Title, '</div>
                <div class="right">
                        <a id="top"> </a><a class="minitext" href="', htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8'), '">☜ ', _('Table of Contents'), '</a><br />
                        <a class="minitext" href="#bottom">⬇ ', _('Go to Bottom'), '</a>


For simplicity, we deployed an Ubuntu machine with webERP v4.15, and deployed an FTP service. Then we did the next:

  1. As an FTP user we created a directory and a file, /srv/ftp/upload/Manual/ManualContents.php, and put call to the phpinfo function.
  2. As a web user, we sent GET request with Language GET parameter:

WebERP v4.15.1 – Authenticated Local File Inclusion

In webERP 4.15.1, the developers commented out the code lines that take the Language parameter from the user input in ManualContents.php. ManualContents.php is now accessible after the authorization only, but user can specify the Language parameter in POST request. Look at “includes/LanguageSetup.php”, lines 15-23.

If (isset($_POST['Language'])) {
	$_SESSION['Language'] = $_POST['Language'];
	$Language = $_POST['Language'];
} elseif (!isset($_SESSION['Language'])) {
	$_SESSION['Language'] = $DefaultLanguage;
	$Language = $DefaultLanguage;
} else {
	$Language = $_SESSION['Language'];
//Check users' locale format via their language
//Then pass this information to the js for number validation purpose

$Collect = array(

foreach($Collect as $Key=>$Value) {
	if(in_array($Language,$Value)) {
		$Lang = $Key;
		$_SESSION['Lang'] = $Lang;

So we deployed webERP v4.15.1 on the same virtual server, then did the next steps:

  1. Check that the file “/srv/ftp/upload/Manual/ManualContents.php” contains the right payload
  2. Authenticate as a regular webERP user with the default credentials
  3. Send a POST request to ManualContents.php, with Language body parameter.
  4. Navigate to ManualContents.php in a browser.


POST /ManualContents.php HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close
Cookie: PHPSESSIDwebERPteam=abumh3e3ak5ert1afcrpjkl02p
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 44



WebERP support team fixed these vulnerabilities and promised to release a new update on the previous week. So update the webERP application to the latest version as soon as it will be released.
But at the moment, Lyhin’s Lab recommends to change the code at includes/LanguageSetup.php, lines 15-23

If (isset($_POST['Language'])) {
	$_SESSION['Language'] = $_POST['Language'];
	$Language = $_POST['Language'];
} elseif (!isset($_SESSION['Language'])) {
	$_SESSION['Language'] = $DefaultLanguage;
	$Language = $DefaultLanguage;
} else {
	$Language = $_SESSION['Language'];


if (isset($_POST['Language'])) {
	if (preg_match("/^([a-z]{2}\_[A-Z]{2})(\.utf8)$/", $_POST['Language'])) $_SESSION['Language'] = $_POST['Language'];
} else {
	$_SESSION['Language'] = $DefaultLanguage;
	$Language = $DefaultLanguage;
$Language = $_SESSION['Language'];

This change was approved by the webERP support team.

LL advises to all the researchers do not break real applications illegally. This fun leads to broken businesses and lives, and, most likely, will not make an attacker really rich.