본문 바로가기

컴퓨터와 인터넷

리눅스 고스트 취약점 QID123191 확인 및 패치 방법

반응형

리눅스 고스트 취약점 QID123191(CVE-2015-0235) 확인 및 패치 방법


리눅스 고스트 취약점이란? (Ghost Vulnerability)

리눅스 glib  라이브러리에서 일명 Ghost라고 불리우는 취약점 발견됨.

이 취약점을 악용할 경우 시스템에 대한 제어권을 획득가능.

고스트는 2000년 11월 10일부터 배포되기 시작한 

glibc-2.2를 기반으로 한 시스템들은 모두 영향을 받을 수 있다.


고스트 취약점 패치방법


Glibc 버전을 확인하자. 

ldd --version


결과화면




고스트 취약점에 영향을 받는지 확인해보는 방법.

vi ghosttest.c 아래 내용을 입력

/* ghosttest.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);

}

gcc ghosttest.c -o ghosttest

./ghosttest 로 실행

다운로드 : ghosttest.c 코드 

ghosttest.txt


위 코드를 작성하여 실행하였을때 vulnerable 이라 나오면 패치를 해줘야 하며.

not vulnerable이라 나오면 취약하지 않다는 뜻이된다.


Glibc 취약점에 영향을 받은 패키지나 어플리케이션을 조회하는 방법

lsof | grep libc | awk '{print $1}' | sort | uniq


취약점 패치방법

sudo yum clean all

sudo yum update

sudo reboot


업데이트 후 다시 glibc 버전 확인과  ghosttest를 실행하여 확인해보도록 하자.

ldd --version

./ghosttest


출처: http://www.cyberciti.biz/faq/cve-2015-0235-patch-ghost-on-debian-ubuntu-fedora-centos-rhel-linux/




반응형