OpenBSD CHPass不安全临时文件符号链接漏洞发布时间:2003-02-03 更新时间:2003-02-03 严重程度:高 威胁程度:读取受限文件 错误类型:访问验证错误 利用方式:客户机模式 BUGTRAQ ID:6748 受影响系统 OpenBSD OpenBSD 2.6详细描述 OpenBSD的chpass存在一个漏洞,本地用户可以利用chpass文件符号链接漏洞访问指定文件的内容。 不过目标文件的有些行必需使用指定格式。 chfn和chsh程序是chpass程序的硬链接也存在存在同样的漏洞。 解决方案 Marc Bevand <bevand_m@epita.fr>提供了如下第三方补丁程序: http://www.epita.fr/~bevand_m/asa/asa-0001.openbsd-chpass.cvs-diff ---8<-------------- asa-0001.openbsd-chpass.cvs-diff ----------------- Index: edit.c =================================================================== RCS file: /cvs/src/usr.bin/chpass/edit.c,v retrieving revision 1.23 diff -u -r1.23 edit.c --- edit.c 31 Jul 2002 22:08:42 -0000 1.23 +++ edit.c 2 Feb 2003 18:34:02 -0000 @@ -48,6 +48,7 @@ #include <ctype.h> #include <err.h> #include <errno.h> +#include <fcntl.h> #include <paths.h> #include <pwd.h> #include <stdio.h> @@ -152,12 +153,14 @@ char *p, *q; ENTRY *ep; FILE *fp; + int fd; - if (!(fp = fopen(tempname, "r"))) + if ((fd = open(tempname, O_RDONLY|O_NOFOLLOW)) == -1 || + (fp = fdopen(fd, "r")) == NULL) pw_error(tempname, 1, 1); - if (fstat(fileno(fp), &sb)) + if (fstat(fd, &sb)) pw_error(tempname, 1, 1); - if (sb.st_size == 0) { + if (sb.st_size == 0 || sb.st_nlink != 1) { warnx("corrupted temporary file"); goto bad; } ---8<-------------- asa-0001.openbsd-chpass.cvs-diff ----------------- 相关信息 发现者:Marc Bevand <bevand_m@epita.fr> 相关信息:http://online.securityfocus.com/archive/1/309962 |