- 热门文章:
- · Linux下软件的安装与卸载
- · 学习设置端口映射
- · 收藏经典:windows消息大全
- · 一行代码崩溃IE
- · 脚本安全和利用
- · 亲手打造一个QQ恶作剧程序
- · CCIE:年薪翻了两倍
- · Linux认证基本知识介绍
- · 思科认证考生问答集
- · 微软认证考试的几种形式
- · 利用SSH从外网安全地访问PIX防火墙
- · 多网段环境下的Windows文件夹共享解决
上一篇:Google还可以这样用 >>
Smail堆溢出漏洞允许远程攻击者获得Root权限
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_mlogwrite_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;
()
下一篇:Linux下软件的安装与卸载 >>
相关文章:
- · 防火墙中使用Telnet、FTP、RealAudio
- · 网络经典命令行-网络安全工作者必杀技
- · Java 程序编码规范
- · FTP 鸡肉制作
- · 安全程序员必读书籍清单
- · 编辑web.config,保证ASP.NET的安全
- · 修复ADSL的Firmware之手记
- · Microsoft平台下的find在网络管理中的妙用
- · 利用组策略对象(GPOs)防止匿名登录
- · 删除系统顽固文件的十二招技巧
- · DoS攻击隐身于合法指令中 难以完全阻绝
- · 我能躲到哪里去?—无线定位技术
- · Windows“安全模式”的五项用途
- · ECHO命令的超详细使用
- · php注入专题
- · 对IPv6在NGI核心层和接入层部署的思考
- · IDS(入侵检测系统)术语
- · 如何用好双WAN路由器
- · 使用IP过滤,轻松管理网络
- · CHKDSK(磁盘检测)命令的运用
- · Linux下口令恢复任我行
- · 使用FlashFXP来提升权限
- · 部署防火墙策略的十六条守则
- · TopStyle Pro 使用技巧
- · 21分钟解决struts国际化和中文问题
- · WindowsNT/2K/XP/2K3系统实用工具集
- · TOPSEC网络安全体系平台
- · 巧用比较并合并文档 RPC服务启用的方法
- · Windows管道技术简述
- · 消除防火墙的局限性和脆弱性
- · Win2003作路由 局域网共享多出口上网
- · dvdrip、dvdscr、tc版等的区别
- · Windows2000/XP服务攻略
- · 破解加密光盘五法破解加密光盘五法
- · 常用的DDOS软件+动画教程
- · 教你申请10GB免费网络硬盘
- · 人在江湖安全第一 使用SNMP服务的安全防范
- · NT系统的门卫——SAM
