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) -16sizeof(unsigned char) - 2sizeof(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); }</pre>將上述代碼內容保存為GHOST.c,執行:
gcc GHOST.c -o GHOST$./GHOST vulnerable //表示存在漏洞,需要進行修復。
$./GHOST notvulnerable //表示修復成功。</pre>
建議修補方案
特別提示:由于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 update apt-get install libc6
Debian 7
apt-get update apt-get install libc6openSUSE 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</div> 來自:http://www.linuxde.net/2015/01/15662.html