201502041712CVE-2015-0235 CentOS 修補 glibc 的 Ghost 漏洞
Qualys漏洞實驗室總監Amol Sarwate表示,他們在glibc的 __nss_hostname_digits_dots() 功能中發現一個緩衝區溢位漏洞,只要是經由本機或遠端各種將網站名稱轉成IP位址的gethostbyname*() 功能就可觸發該漏洞,駭客可藉以掌控受駭系統,自遠端執行任何程式。由於此一漏洞是經由GetHOST功能觸發,因而被簡稱為GHOST。
參考資料:
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-0235
https://access.redhat.com/security/cve/CVE-2015-0235 (Redhat、CentOS 受影響範圍可以參考此篇)
http://www.ithome.com.tw/news/93791 (中文說明)
http://blog.longwin.com.tw/2015/01/linux-glibc-ghost-vulnerability-patch-fix-2015/ (中文說明)
http://www.openwall.com/lists/oss-security/2015/01/27/9
問題來源已寫在第一段,後面將說明在 CentOS 環境該如何解決。
測試方法:
利用底下這段程式碼(假設檔名為 ghost.c),來偵測 glibc 函示庫裡的 gethostbyname() 是否存在著 overflow 的問題
gcc ghost.c -o ghost #編譯 compiler 此測試程式
./ghost #執行此測試程式
若系統中的 glibc 有問題會出現「vulnerable」,沒問題則為「not vulnerable」
/* ghost.c: GHOST vulnerability tester */
/* Credit: http://www.openwall.com/lists/oss-security/2015/01/27/9 */
#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("not vulnerable");
exit(EXIT_SUCCESS);
}
puts("should not happen");
exit(EXIT_FAILURE);
}
有問題的 glibc 版本 <---> 升級後沒問題的版本
[CentOS4] glibc i686/x86_64 2.3.4 2.43.el4_8.3 <---> glibc i686/x86_64 2.3.4 2.54 (還沒測試過,不知是否能滿足 ghost 的測試)
[CentOS5] glibc i686/x86_64 2.5 58.el5_6.4 <---> glibc i686/x86_64 2.5 123.el5_11.1
[CentOS6] glibc i686/x86_64 2.12 1.132.el6 <---> glibc i686/x86_64 2.12 1.149.el6_6.5
解決方法:
既然問題的來源是「GHOST gethostbyname() heap overflow in glibc」,所以我們就可以透過此方法
sudo yum update glibc
來更新 glibc ,更新時他會連帶的升級底下幾個套件
(1/6): nscd-2.5-123.el5_11.1.x86_64.rpm
(2/6): glibc-headers-2.5-123.el5_11.1.x86_64.rpm
(3/6): glibc-devel-2.5-123.el5_11.1.x86_64.rpm
(4/6): glibc-2.5-123.el5_11.1.x86_64.rpm
(5/6): glibc-2.5-123.el5_11.1.i686.rpm
(6/6): glibc-common-2.5-123.el5_11.1.x86_64.rpm
如果你的環境沒安裝 gcc 但系統卻有 glibc 這個漏洞問題,於是你可能會安裝 gcc
sudo yum install -y gcc
然後你會發現,他會連 glibc 一併的幫你更新了,這個系統漏洞也一併解決。
如此更新之後,利用上面的 ghost.c 測試程式已經可以獲得「not vulnerable」的結果,但實際上我覺得大家最近還是應該多觀察系統的狀態。
~End