首页 -> 安全研究

安全研究

安全漏洞
Middleman net_dns()帧指针覆盖漏洞

发布日期:2003-01-10
更新日期:2003-01-20

受影响系统:
Middleman Middleman 1.2
Middleman Middleman 1.1
Middleman Middleman 1.0
Middleman Middleman 0.9.9
描述:
BUGTRAQ  ID: 6584

Middleman是一款功能强大的代理服务程序。

Middleman中包含的执行主机名DNS查询的函数存在漏洞,远程攻击者可以利用这个漏洞进行单字节缓冲区溢出攻击,可能以root用户权限在系统上执行任意指令。

在Middleman中的src/networks.c文件中存在如下代码:

/*
perform a dns lookup, using cached response from a previous lookup if possible
*/
HOSTENT *net_dns(char *host)
{
        time_t t;
        char *string, hst[128], buf[24];
        HOSTENT *hostent;

以上在堆栈中的内存分布结构如下:

hst[128]        |
string[4]        |
t[4]            |
ebp            |
eip            V

在src/networks.c 627行使用我们发现使用了如下函数:

s_strncpy(hst, host, 128);

以上拷贝操作时会由于拷贝0x00字节而造成单字节溢出问题,不过按照上面内存分布图看起来不会有实际漏洞出现,因为0x00只会覆盖字符串的第一个字节,但是由于编译或优化问题,这些变量以实际不同方式存储在堆栈中,实际内存分布如下:

** net_dns(): &hst 0xbf7ff9f4 &string 0xbf7ff9d4 &t 0xbf7ff9d8


string[4]        |
t[4]            |
hst[128]        |
ebp                     |
eip                     V

因此如果主机名超过128字节,就可以导致覆盖帧指针最后一个字节,精心构建主机名数据可能以root用户权限在系统上执行任意指令。

<*来源:qitest1 (qitest1@bespin.org
  
  链接:http://marc.theaimsgroup.com/?l=bugtraq&m=104232320920783&w=2
*>

建议:
临时解决方法:

如果您不能立刻安装补丁或者升级,NSFOCUS建议您采取以下措施以降低威胁:

* qitest1 <qitest1@bespin.org>提供如下第三方补丁:

- --- middleman/src/misc.c 2002-10-19 19:07:24.000000000 +0200
+++ middleman-patched/src/misc.c 2003-01-10 11:29:08.000000000 +0100
@@ -27,17 +27,34 @@
#include <sys/types.h>
#include "proto.h"

- -/*
- -strncpy which always NULL terminates
- -*/
- -char *s_strncpy(char *d, char *s, size_t len)
- -{
- - char *dest = d;
- -
- - for (; len && (*dest = *s); s++, dest++, len--);
- - *dest = '\0';
+ /* Adapted version of OpenBSD strlcpy */
+char *
+s_strncpy(dst, src, siz)
+ char *dst;
+ char *src;
+ size_t siz;
+{
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0) {
+ do {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }

- - return d;
+ return dst;
}

/*

厂商补丁:

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

http://www.sourceforge.net/projects/middle-man

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