Bobcares

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

by | Jan 27, 2015

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

 

0 Comments

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF