安全研究

安全漏洞
PeerCast getAuthUserPass函数栈溢出漏洞

发布日期:2008-04-29
更新日期:2008-05-04

受影响系统:
Peercast Peercast 0.1218
GNOME PeerCast 0.5.4
描述:
BUGTRAQ  ID: 28986
CVE(CAN) ID: CVE-2008-2040

PeerCast是一款简单易用的音频/视频流媒体服务器。

PeerCast的HTTP::getAuthUserPass()函数在处理HTTP Basic认证请求时存在栈溢出漏洞,如果远程攻击者提交了超长的HTTP Basic认证字符串就可以触发这个溢出,导致拒绝服务或执行任意指令。

以下是core/common/http.cpp中的漏洞代码:

105 void HTTP::getAuthUserPass(char *user, char *pass)
106 {
107         if (arg)
108         {  
109                 char *s = stristr(arg,"Basic");
110                 if (s)
111                 {  
112                         while (*s)
113                                 if (*s++ == ' ')
114                                         break;
115                         String str;
116                         str.set(s,String::T_BASE64);
117                         str.convertTo(String::T_ASCII);
118                         s = strstr(str.cstr(),":");
119                         if (s)
120                         {  
121                                 *s = 0;
122                                 if (user)
123                                         strcpy(user,str.cstr());
124                                 if (pass)
125                                         strcpy(pass,s+1);

如果通过basic http认证而不是cookie对peercast服务器进行认证的话就会使用这个函数,在116行将base64编码的字符串拷贝到了str。请注意set方式是peercast自己的set实现,因为重新实现了String类。set类似于:

core/common/sys.h:
38                 MAX_LEN = 256
...
62         void set(const char *p, TYPE t=T_ASCII)
63         {  
64                 strncpy(data,p,MAX_LEN-1);
65                 data[MAX_LEN-1] = 0;
66                 type = t;
67         }  

在117行解码字符串,在118行将解码字符串中“:”之前的部分拷贝到了user,之后的部分拷贝到了pass。

core/common/servhs.cpp:
558 bool Servent::handshakeAuth(HTTP &http,const char *args,bool local)
559 {
560         char user[64],pass[64];
561         user[0] = pass[0] = 0;
...
580     while (http.nextHeader())
581         {  
582                 char *arg = http.getArgStr();
583                 if (!arg)
584                         continue;
585
586                 switch (servMgr->authType)
587                 {  
588                         case ServMgr::AUTH_HTTPBASIC:
589                                 if (http.isHeader("Authorization"))
590                                         http.getAuthUserPass(user,pass);
591                                 break;

在558行user和pass仅声明为64字节,而用于拷贝的缓冲区可最多储存MAX_LEN(256)字节,之后Servent::handshakeAuth调用getAuthUserPass函数就可能触发缓冲区溢出。

<*来源:Nico Golde (nion@debian.org
  
  链接:http://secunia.com/advisories/29962/
        http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=478573
        http://secunia.com/advisories/30020/
        http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=478680
        http://www.debian.org/security/2008/dsa-1582
        http://www.debian.org/security/2008/dsa-1583
        http://security.gentoo.org/glsa/glsa-200807-11.xml
*>

测试方法:

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=peercast.py;att=1;bug=478680

建议:
厂商补丁:

Debian
------
Debian已经为此发布了一个安全公告(DSA-1583-1)以及相应补丁:
DSA-1583-1:New gnome-peercast packages fix several vulnerabilities
链接:http://www.debian.org/security/2008/dsa-1583

补丁下载:
Source archives:

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0.dsc
Size/MD5 checksum:      956 e2d40d2cd79ac54cefb00a6fa9b747d2
http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0.diff.gz
Size/MD5 checksum:     3104 a17daf736115641d4ab3a6c41aa152c3
http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4.orig.tar.gz
Size/MD5 checksum:   800116 e689715d8e70cdb0ce684ccce063a58f

alpha architecture (DEC Alpha)

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0_alpha.deb
Size/MD5 checksum:   296926 b1ebff0148fc69634eede7fffc114d51

amd64 architecture (AMD x86_64 (AMD64))

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0_amd64.deb
Size/MD5 checksum:   257812 33d4c4fd7bed425a4cee0268e44dcc20

hppa architecture (HP PA RISC)

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0_hppa.deb
Size/MD5 checksum:   297822 e5795eb9b0d5d08d042825e05c04c0f7

i386 architecture (Intel ia32)

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0_i386.deb
Size/MD5 checksum:   254172 a6e46c6422c8a76df706375cba85461e

ia64 architecture (Intel ia64)

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0_ia64.deb
Size/MD5 checksum:   346408 34f8ffc5f763a013ff5bc87832bdf77a

mips architecture (MIPS (Big Endian))

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0_mips.deb
Size/MD5 checksum:   285802 62e99808d3a9a015139500c92b595089

mipsel architecture (MIPS (Little Endian))

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0_mipsel.deb
Size/MD5 checksum:   284316 f84d8576550138d846b5f3e6790db54f

powerpc architecture (PowerPC)

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0_powerpc.deb
Size/MD5 checksum:   270324 e83511effbc2f89183145dae92e27ecf

s390 architecture (IBM S/390)

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0_s390.deb
Size/MD5 checksum:   260410 ac50ca3aa93414140f955f131fa050bc

sparc architecture (Sun SPARC/UltraSPARC)

http://security.debian.org/pool/updates/main/g/gnome-peercast/gnome-peercast_0.5.4-1.1etch0_sparc.deb
Size/MD5 checksum:   251018 5ff3b23b8ec68fa47ed19f8abafac669

补丁安装方法:

1. 手工安装补丁包:

  首先,使用下面的命令来下载补丁软件:
  # wget url  (url是补丁下载链接地址)

  然后,使用下面的命令来安装补丁:  
  # dpkg -i file.deb (file是相应的补丁名)

2. 使用apt-get自动安装补丁包:

   首先,使用下面的命令更新内部数据库:
   # apt-get update
  
   然后,使用下面的命令安装更新软件包:
   # apt-get upgrade

Gentoo
------
Gentoo已经为此发布了一个安全公告(GLSA-200807-11)以及相应补丁:
GLSA-200807-11:PeerCast: Buffer overflow
链接:http://security.gentoo.org/glsa/glsa-200807-11.xml

所有PeerCast用户都应升级到最新版本:

   # emerge --sync
   # emerge --ask --oneshot --verbose ">=media-sound/peercast-0.1218-r1"

Peercast
--------
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:

http://www.peercast.org/

浏览次数:3096
严重程度:0(网友投票)
本安全漏洞由绿盟科技翻译整理,版权所有,未经许可,不得转载
绿盟科技给您安全的保障