Select Page

GHOST hunting – Resolving glibc Remote Code Execution vulnerability (CVE-2015-0235) in CentOS, Red Hat, Ubuntu, Debian and SUSE Linux servers

GHOST hunting – Resolving glibc Remote Code Execution vulnerability (CVE-2015-0235) in CentOS, Red Hat, Ubuntu, Debian and SUSE Linux servers

Reports are coming in from our Dedicated Linux Systems Administrators about an evolving threat, disclosed earlier today.

A heap buffer overflow vulnerability in GNU C Library (glibc), allows remote or local actors to execute arbitrary code under the privilege of user running the function gethostbyname(). Qualsys, who reported the bug was able to remotely exploit this bug in an Exim mail server.

Linux servers with stable distributions marked as long term support are likely to be affected by this bug (CVE-2015-0235). The distributions we have counted till now include:

Red Hat or CentOS 5.x, 6.x, 7.x
Debian 7
Ubuntu 12.04
SUSE 11 or older

If your glibc version is lower than 2.18, you should assume that your server is vulnerable. You can check the version as given below:

root@sev # find /lib/ -name libc.so.*
/lib/libc.so.6

root@sev # /lib/libc.so.6
GNU C Library stable release version 2.12, by Roland McGrath et al.

Alternatively, you can use the below vulnerability test program released by Qualsys. (Disclaimer: Use this program at your own risk. We execute these programs under a restricted environment.)

Save the following into a file named ghost.c

#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] = '';
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);
}


Compile it using:
# gcc ghost.c -o ghost

Run it using:
# ./ghost

You'll see an output saying "vulnerable" if your server is affected by the bug.

Patches are being prepared by major distro vendors for vulnerable versions. We are closely monitoring the situation, and this post will be updated with details of the fix once the patches are available.
In the mean time, you can implement immediate limited threat mitigation by disabling reverse DNS checks in all your public facing services. For example, you can disable reverse DNS checks in SSH by setting “UseDNS” to “no” in /etc/ssh/sshd_config.
UPDATE 28th Jan :  All major distros have released patches for glibc. Here’s how you can update your servers

For Red Hat / Cent OS / Cloud Linux, do the following:

# yum clean all
# yum update
# reboot

For Debian / Ubuntu, do the following:

# apt-get clean
# apt-get update
# apt-get dist-upgrade
# reboot

For SUSE, do the following:

SUSE Linux Enterprise Software Development Kit 11 SP3:
zypper in -t patch sdksp3-glibc-10206

SUSE Linux Enterprise Server 11 SP3 for VMware:
zypper in -t patch slessp3-glibc-10206

SUSE Linux Enterprise Server 11 SP3:
zypper in -t patch slessp3-glibc-10206

SUSE Linux Enterprise Server 11 SP2 LTSS:
zypper in -t patch slessp2-glibc-10204

SUSE Linux Enterprise Server 11 SP1 LTSS:
zypper in -t patch slessp1-glibc-10202

SUSE Linux Enterprise Desktop 11 SP3:
zypper in -t patch sledsp3-glibc-10206

To bring your system up-to-date, use "zypper patch".

 

For a FREE vulnerability assessment and EXPRESS patching, sign up below:

Fix GHOST vulnerability

If you’d like to have your servers always protected against evolving threats, and prompt securing, check out our server management services below:

Dedicated Server Administrators      Proactive Server Management

 


Bobcares
Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.
MORE ABOUT BOBCARES