Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to detect and repair Linux Glibc Library Security vulnerabilities

Shulou Source: shulou.com Published: 2022-06-01 07:53:49 09月22日 Update

This article mainly explains "how to detect and fix Linux Glibc library security vulnerabilities". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to detect and fix Linux Glibc library security vulnerabilities.

On January 27th, 2015, the gethostbyname function of the Linux GNU glibc standard library exposed a buffer overflow vulnerability numbered CVE-2015-0235. Hackers can use gethostbyname series functions to achieve remote code execution and gain control of the server and Shell permissions. This vulnerability triggers many ways and affects a wide range of software and systems that have been successfully exploited: Glibc 2.2 to 2.17 (including 2.2 and 2.17 versions).

A buffer overflow vulnerability has been exposed in the gethostbyname function of the GNU glibc standard library, vulnerability number: CVE-2015-0235. Glibc is a C library that provides system calls and basic functions, such as open, malloc, printf, etc. All dynamically linked programs use Glibc. A remote attacker can exploit this vulnerability to execute arbitrary code and elevate the privileges of the user running the application.

Vulnerability detection method

Just follow the instructions:

The code is as follows:

# include

# include

# include

# include

# include

# define CANARY "in_the_coal_mine"

Struct {

Char buffer [1024]

Char bank [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, '0mm, 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 ("notvulnerable")

Exit (EXIT_SUCCESS)

}

Puts ("should nothappen")

Exit (EXIT_FAILURE)

}

Save the above code as GHOST.c, and execute:

The code is as follows:

Gcc GHOST.c-o GHOST

$. / GHOST

Vulnerable / / indicates that there is a vulnerability that needs to be fixed.

$. / GHOST

Notvulnerable / / indicates that the repair is successful.

Suggested patching scheme

Special note: since glibc is a basic component of the Linux system, in order to avoid the impact of patching on your server, it is recommended that you choose the appropriate time to repair, and be sure to backup through snapshot operation before repair.

CentOS 5-6-7

The code is as follows:

Yum update glibc

Ubuntu 12/14

The code is as follows:

Apt-get update

Apt-get install libc6

Debian 6

The code is as follows:

Wget-O / etc/apt/sources.list.d/debian6-lts.list http://mirrors.aliyun.com/repo/debian6-lts.list

Apt-get update

Apt-get install libc6

Debian 7

The code is as follows:

Apt-get update

Apt-get install libc6

OpenSUSE 13

The code is as follows:

Zypper refresh

Zypper update glibc*

Aliyun linux 5u7

The code is as follows:

Wget-O / etc/yum.repos.d/aliyun-5.repo http://mirrors.aliyun.com/repo/aliyun-5.repo

Yum update glibc

Thank you for your reading, the above is the content of "how to detect and repair Linux Glibc library security vulnerabilities". After the study of this article, I believe you have a deeper understanding of how to detect and repair Linux Glibc library security vulnerabilities, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Vulnerabilities code detection security vulnerabilities functions content systems learning success suggestions servers permissions standards programs buffers patches impacts services buffers Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology Linux Apple MySQL