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/p>
p>$./GHOST
vulnerable //表示存在漏洞,需要進行修復。/p>
p>$./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 a >http://mirrors.aliyun.com/repo/debian6-lts.list/a>
apt-get update
apt-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 a >http://mirrors.aliyun.com/repo/aliyun-5.repo/a>
yum update glibc