Categories: Security

CVE-2015-0235 – How to secure against Glibc Ghost Vulnerability

CVE-2015-0235 Ghost (glibc gethostbyname buffer overflow) Vulnerability is serious cause for all Linux servers. This vulnerability leveraged to execute remote and  code execution on the victim Linux server. The vulnerability found By Qualys Researcher and patched in GNU.

 

What is the cause ?

The bug is in __nss_hostname_digits_dots() function of function of the GNU C Library (glibc), and location of the path is file for  non-reentrant version is nss/getXXbyYY.c , which is used by the gethostbyname().  The vulnerability can be exploited both via locally and remotely.  In order to trigger this vulnerability attacker needs to be able to feed specially crafted ‘host name’ to the service. And service needs to process it without validating it first.

 

Following are the potentially exploitable services

  1. procmail
  2. Exim
  3. pppd
  4. clockdiff

 

You can find the list of services which are rely on the GNU C libraries by executing following command
lsof | grep libc | awk ‘{print $1}’ | sort | uni

Fix for Centos/RHEL/Fedora 5,6,7

yum update glibc
sudo restart

Fix for Ubuntu

sudo apt-get update
sudo apt-get dist-upgrade
sudo restart

For Quick test , you can run this code



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

Vishwajit Kale
Vishwajit Kale blazed onto the digital marketing scene back in 2015 and is the digital marketing strategist of Hostripples, a company that aims to provide affordable web hosting solutions. Vishwajit is experienced in digital and content marketing along with SEO. He's fond of writing technology blogs, traveling and reading.

Recent Posts

The Ultimate Guide to WordPress Maintenance: Tips and Tricks

When you’re running a business that relies on website traffic and sales to succeed. Then you need to keep it…

1 week ago

Migrate In 2024: Our Comprehensive Website Migration Manual to the Next Level

Migration! Yes, this word is very big in the web hosting industry and it has its importance. Especially for businesses…

2 weeks ago

Unveiling the Importance of Server Maintenance Plans: A Comprehensive Guide

The server is the backbone of the web hosting industry and it acts like a HERO in the web hosting…

3 weeks ago

IP Address is Blocked? A handpicked list of Solutions to Fix it?

Imagine you are on holiday having a cup of tea and browsing your website or blog.Then, what next?You will get…

4 weeks ago

Explained: Difference between Nameservers Vs. DNS

The web hosting industry is growing every minute, day, and year. It has many terminologies that are important to understand…

1 month ago