Lucene search

K
seebugRootSSV:3476
HistoryJun 25, 2008 - 12:00 a.m.

TMSNC UBX消息远程栈溢出漏洞

2008-06-2500:00:00
Root
www.seebug.org
22

EPSS

0.049

Percentile

92.8%

BUGTRAQ ID: 29850
CVE(CAN) ID: CVE-2008-2828

TMSNC是用C编写的基于文本的MSN客户端。

TMSNC在处理畸形结构的消息数据时存在漏洞,如果远程攻击者向TMSNC发送了畸形的UBX消息消息的话,就可能触发缓冲区溢出,导致执行任意指令。

UBX是类似于UUX的MSN协议,用于通知好友所发生的变化。UBX协议命令的第一个参数为更改了个人消息或当前正在播放歌曲的联络人的护照地址,第二个参数为负载的长度,句法如下:

>>> UBX [email protected] xxx\r\n
<Data><PSM>My Personal Message</PSM><CurrentMedia></CurrentMedia></Data>

UBX协议是由tmsnc的core_net.c文件中以下代码解析的:

727 int
728 MSN_server_handle(session, message, message_len)
729      MSN_session *session;
730      char *message;
731      int message_len;
732 {
733     time_t tm;
734     char buf[512], md_hex[48];
...
748     while (getline(buf, sizeof(buf) - 1, session-&gt;sd) &gt; 0) {
...
833         } else if (strncmp(buf, &quot;UBX&quot;, 3) == 0) {
834             /*
835              * we read the payload of this command·
836              */
837             /*
838              * but do not do anything with it······
839              */
840             if ((ptr[1] = (char *)split(buf, ' ', 1)) == NULL ||        //by gfhuang
841                 (ptr[0] = (char *)split(buf, ' ', 2)) == NULL) {
842                 strncpy(message, &quot;Couldn't parse UBX&quot;, message_len - 1);
843                 return -1;
844             }
845             i = atoi(ptr[0]);
846             free(ptr[0]);
847·
848             if (read(session-&gt;sd, buf, i) != i) {
849                 strncpy(message, &quot;Couldn't read UBX payload&quot;,
850                         message_len - 1);
851                 return -1;
852             }
853             // parsing PSM, by gfhuang
854             if(0 == i) buf[0] = 0;      //important, by gfhuang, when i=0, buf is untouched!

在734行消息缓冲区声明为存储512字节的数据,748行读取来自好友联系人的命令行,而如果消息缓冲区包含有类似于以下的UBX消息的话:
UBX [email protected] xxx\r\n (这里xxx为UBX负载长度)

就会使用833及之后的行。

如果缓冲区的前三个字节匹配UBX且字符串包含有两个传送给ptr[1]和ptr[0]的空间的话,就是一个有效的UBX消息。

split函数来自core_misc.c,基本类似于strchr函数,将指针返回给作为第二个参数的第一个字符串。因此在841行的调用后,ptr[0]会指向消息长度,然后在845行使用atoi将这个值转换为整数并在848行传送给read函数,之后通过会话套接字从MSN报文读取UBX负载。因此如果将UBX负载声明为大于sizeof(buffer)或负载长于sizeof(buffer)的话,就会触发栈溢出,导致执行任意指令。

TMSNC 0.3.2
TMSNC

目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:

<a href=“http://tmsnc.sourceforge.net/index.html” target=“_blank”>http://tmsnc.sourceforge.net/index.html</a>

EPSS

0.049

Percentile

92.8%