| 网站首页 | 资讯 | Hack | 漏洞 | 网管 | 编程 | 培训 | 品黑页 | 软件 | 论坛 | 动画 | 视频 | 经典 | 教学站 | 黑客点睛 | 
服务导航 我要发布 主力频道 空间域名 精华收集 服务器出租 黑客培训 光盘刻录 特色服务 解决方案 我要投诉
您现在的位置: 华夏黑客同盟 >> 漏洞 >> 最新漏洞 >> *INX 漏洞 >> 正文 用户登录 新用户注册
Smail堆溢出漏洞 攻击者可获得Root权限         ★★★★ 【字体:
Smail堆溢出漏洞允许远程攻击者获得Root权限
作者:佚名 文章来源:securitytracker.com 点击数: 更新时间:2005-3-31
Summary:

There is a heap buffer overflow, and a signal handling related vulnerability.
The heap buffer overflow can be exploited by remote users, or local users, and
allows for code execution with root permissions. The signal handling related
vulnerability can possibly be exploited by a local user to execute code with
root permissions.

++++++++++++++++++++++++++++++++++++++++++++

Details:

-------------------------------------------------------------------------------
Heap bof is exploitable by anyone who can connect to smail smtp server. It
happens in the MAIL FROM command, among others.

-------------------------------------------------------------------------------
file: addr.c +218
-------------------------------------------------------------------------------

if (*ap == '@') {
/* matched host!(host!)*@route -- build the !-route */
1] register char *p = xmalloc((size_t) strlen(address));
DEBUG(DBG_ADDR_MID, "found host!(host!)*@route form--ugh!\n");
/* first part already !-route */
2] strncpy(p, address, (size_t) (ap - address)); /* HOLE */
if (mark_end) {
*mark_end++ = '>'; /* widden the original address */
}
3] ap = build_uucp_route(ap, error, 0); /* build !-route */
if (ap == NULL) {
DEBUG1(DBG_ADDR_LO,
"preparse_address(): build_uucp_route() failed: %s: returns:
(null)\n", *error);
return NULL;
}
4] strcat(p, ap); /* concatenate together */
xfree(ap);
DEBUG1(DBG_ADDR_HI, "preparse_address returns: %v\n", p);
*rest = mark_end;
return p; /* transformed */
}

1) Here we allocate a buffer on the heap. The address string is user
provided source email address.
2) Here we copy in (ap - address) bytes. ap is a pointer into the address
buffer. It's plain to see that with this copy we will not append a NULL
byte to the p string.
3) Here we build the route part of the address with more user supplied data.
4) Now the route gets appended to p string. Since the string was not
properly NULL terminated, we'll start appending from the first NULL byte
found past it on the heap. In my testing I found we can easily trigger this
overflow condition with a wide variety of buffer sizes. Furthermore, we
can reliably create a known heap setup by first crashing process, and then
using other commands to allocate buffers of a known size that will be freed,
and then triggering this allocation and grabbing one of the known previously
freed buffers.

Mitigating factors:

+the overflow buffer is limited to RFC 821 (Section 4.1.2. COMMAND SYNTAX)
characters, but we can inject shellcode into plenty of other places. For
example, using the HELP command we can inject up to 1024 bytes of data into
a heap buffer that gets leaked and never freed.

-------------------------------------------------------------------------------

Signal handling vuln is exploitable by local console user. Signal handlers are
setup that do all sorts of dangerous things that signal handlers are not
supposed to do. One of the more serious crimes is allocating and freeing heap
buffers.

-------------------------------------------------------------------------------
file: modes.c
-------------------------------------------------------------------------------

void
input_signals()

if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
if (signal(SIGHUP, sig_unlink) == SIG_ERR) {
write_log(WRITE_LOG_SYS, "input_signals(): signal(SIGHUP) failed: %s.",
strerror(errno)); exitvalue = EX_OSERR;
}
}
if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
if (signal(SIGINT, sig_unlink) == SIG_ERR) {
write_log(WRITE_LOG_SYS, "input_signals(): signal(SIGINT) failed: %s.",
strerror(errno)); exitvalue = EX_OSERR;
}
}

...snip...

static void
sig_unlink(sig) /* HOLE */
int sig;

(void) signal(sig, SIG_IGN);
unlink_spool();
write_log(WRITE_LOG_TTY, "interrupt: mail message removed");
exit(EX_OSERR);


...snip...

write_log(int who, char *fmt, ...)
int who; /* mask of log files to be written */
char *fmt; /* printf(3) format */
va_dcl /* arguments for printf */

va_list ap;

...snip...

if (errfile && ((who & WRITE_LOG_TTY) ||
((who & (WRITE_LOG_MLOG|WRITE_LOG_PANIC)) &&
(error_processing == TERMINAL ||
error_processing == ERROR_DEFAULT) && /* XXX ??? */
fmt[0] != 'X'))) {
VA_START(ap, fmt);
write_log_va(WRITE_LOG_TTY, fmt, ap);
va_end(ap);
}

...snip...

static void
write_log_va(who, fmt, ap)
int who; /* mask of log files to be written */
char *fmt; /* printf(3) format */
va_list ap; /* arguments for vfprintf() */

static struct str logstr;
static int initialised = FALSE;

if (!initialised) {
STR_INIT(&logstr);
initialised = TRUE;
} else {
STR_CLEAR(&logstr);
STR_CHECK(&logstr);
}
str_printf_va(&logstr, fmt, ap);

...snip...

#define STR_INIT(sp) \
(((sp)->a = STR_BUMP), \
((sp)->i = 0), \
((sp)->p = xmalloc((sp)->a)))

+ You can see that xmalloc, which then calls malloc, is called from signal
handler. There are many other cases where this is present, as well as other
unsafe calls. Since this is a local hole, we have a lot of control over
the evolution of the heap, such as through addresses we give on command
line, as well as other dynamic variables. Interrupting a main thread call
to syslog(), malloc(), free(), or some other similar situation might yield
for local root if done correctly. I haven't pursued this bug, so I'm not
sure if this is possible or not.

-------------------------------------------------------------------------------

++++++++++++++++++++++++++++++++++++++++++++

Workaround:

None. Patch or die. Fixing the signal handling problems are more serious as
they represent a design flaw.

++++++++++++++++++++++++++++++++++++++++++++

a patch for the overflow:

--- addr.c 2004-08-27 01:46:17.000000000 -0500
+++ _addr.c 2005-03-25 01:00:44.423372480 -0500
@@ -217,10 +217,12 @@
ap++;
if (*ap == '@') {
/* matched host!(host!)*@route -- build the !-route */
- register char *p = xmalloc((size_t) strlen(address));
+ size_t alen = strlen(address);
+ register char *p = xmalloc((size_t) alen + 1);
DEBUG(DBG_ADDR_MID, "found host!(host!)*@route form--ugh!\n");
/* first part already !-route */
strncpy(p, address, (size_t) (ap - address));
+ p[(ap - address)] = '\0';
if (mark_end) {
*mark_end++ = '>'; /* widden the original address */
}
@@ -231,7 +233,8 @@
*error);
return NULL;
}
- strcat(p, ap); /* concatenate together */
+ strncat(p, ap, alen-strlen(p)); /* concatenate together */
+ p[alen] = '\0'; /* in case in wasn't NULL'd */
xfree(ap);
DEBUG1(DBG_ADDR_HI, "preparse_address returns: %v\n", p);
*rest = mark_end;
责任编辑:四海边缘  联系方式  Email:四海边缘
电话:51228163
  • 上一篇漏洞:

  • 下一篇漏洞:
  • 最新hack更新
    最新推荐资讯
    相关漏洞
    availscript相册多个漏洞
    写入注册表读取漏洞利用
    ActiveX控制远程缓冲溢出
    OneNews 多个远程漏洞
    NoName 多个远程漏洞
    MMS协议处理堆溢出
    本地拒绝服务漏洞
    SQL/XSS多个远程漏洞
    多个远程文件包含漏洞
    CMS 远程利用漏洞
    最新会员软件
    最新推荐视频
    最新推荐动画

    Copyright @ 2005 77169.Net Inc. All rights reserved. 华夏黑客同盟 版权所有
    北京市电信通提供网络带宽

    mailto:webmaster@77169.net
    咨询QQ号:836982 / 59280880
    联系站长 QQ38588913
    热线电话: 86-10-67634029/676229433
    京ICP证041431号