Linux Glibc庫嚴重安全漏洞檢測與修復方案

2015年1月27日 Linux GNU glibc標準庫的 gethostbyname函數爆出緩衝區溢出漏洞,漏洞編號爲CVE-2015-0235。***可以通過gethostbyname系列函數實現遠程代碼執行,獲取服務器的控制權及 Shell 權限,此漏洞觸發途徑多,影響範圍大,已確認被成功利用的軟件及系統:Glibc 2.2到2.17 (包含2.2和2.17版本)。

GNU glibc標準庫的gethostbyname 函數爆出緩衝區溢出漏洞,漏洞編號:CVE-2015-0235。 Glibc 是提供系統調用和基本函數的 C 庫,比如open, malloc, printf 等等。所有動態連接的程序都要用到Glibc。遠程***者可以利用這個漏洞執行任意代碼並提升運行應用程序的用戶的權限。

漏洞檢測方法

按照說明操作即可:

#include <netdb.h>   
#include <stdio.h>   
#include <stdlib.h>   
#include <string.h>   
#include <errno.h>   
#define CANARY "in_the_coal_mine"   
struct {   
  char buffer[1024];   
  char canary[sizeof(CANARY)];   
} temp = { "buffer", CANARY };   
int main(void) {   
  struct hostent resbuf;   
  struct hostent *result;   
  int herrno;   
  int retval;   
  /*** strlen (name) = size_needed -sizeof (*host_addr) - sizeof (*h_addr_ptrs) - 1; ***/   
  size_t len = sizeof(temp.buffer) -16*sizeof(unsigned char) - 2*sizeof(char *) - 1;   
  char name[sizeof(temp.buffer)];   
  memset(name, '0', len);   
  name[len] = '\0';   
  retval = gethostbyname_r(name,&resbuf, temp.buffer, sizeof(temp.buffer), &result, &herrno);   
  if (strcmp(temp.canary, CANARY) !=0) {   
    puts("vulnerable");   
    exit(EXIT_SUCCESS);   
  }   
  if (retval == ERANGE) {   
    puts("notvulnerable");   
    exit(EXIT_SUCCESS);   
  }   
  puts("should nothappen");   
  exit(EXIT_FAILURE);
}

將上述代碼內容保存爲GHOST.c,執行:

gcc GHOST.c -o GHOST

$./GHOST
vulnerable   //表示存在漏洞,需要進行修復。

$./GHOST
notvulnerable //表示修復成功。

建議修補方案

特別提示:由於glibc屬於Linux系統基礎組件,爲了避免修補對您服務器造成影響,建議您選擇合適時間進行修復,同時務必在修復前通過快照操作進行備份。

CentOS 5/6/7

yum update glibc

Ubuntu 12/14

apt-get update
apt-get install libc6

Debian 6

wget -O /etc/apt/sources.list.d/debian6-lts.list http://mirrors.aliyun.com/repo/debian6-lts.list
apt-get updateapt-get install libc6

Debian 7

apt-get update
apt-get install libc6

openSUSE 13

zypper refresh
zypper update glibc*

Aliyun linux 5u7

wget -O /etc/yum.repos.d/aliyun-5.repo http://mirrors.aliyun.com/repo/aliyun-5.repo
yum update glibc


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章