您好,日前Linux GNU glibc標(biāo)準(zhǔn)庫(kù)的 gethostbyname函數(shù)爆出緩沖區(qū)溢出漏洞,漏洞編號(hào)為CVE-2015-0235。黑客可以通過(guò)gethostbyname系列函數(shù)實(shí)現(xiàn)遠(yuǎn)程代碼執(zhí)行,獲取服務(wù)器的控制權(quán)及Shell權(quán)限,此漏洞觸發(fā)途徑多,影響范圍大,請(qǐng)大家關(guān)注和及時(shí)臨時(shí)修復(fù)。
一、 漏洞發(fā)布日期
2015年1月27日
二、 已確認(rèn)被成功利用的軟件及系統(tǒng)
Glibc 2.2到2.17 (包含2.2和2.17版本)
三、 漏洞描述
GNU glibc標(biāo) 準(zhǔn)庫(kù)的gethostbyname 函數(shù)爆出緩沖區(qū)溢出漏洞,漏洞編號(hào):CVE-2015-0235。 Glibc 是提供系統(tǒng)調(diào)用和基本函數(shù)的 C 庫(kù),比如open, malloc, printf等等。所有動(dòng)態(tài)連接的程序都要用到Glibc。遠(yuǎn)程攻擊者可以利用這個(gè)漏洞執(zhí)行任意代碼并提升運(yùn)行應(yīng)用程序的用戶的權(quán)限。
四、 漏洞檢測(cè)方法
按照說(shuō)明操作即可。
#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);
}
將上述代碼內(nèi)容保存為GHOST.c
執(zhí)行g(shù)cc GHOST.c -o GHOST
$./GHOST
vulnerable
表示存在漏洞,需要進(jìn)行修復(fù)。
$./GHOST
notvulnerable
表示修復(fù)成功。
五、 建議修補(bǔ)方案
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 libc6
Opensuse 13
zypper refresh
zypper update glibc*