Threat Report

Critical OpenSSH Vulnerability: CVE-2024-6387 (regreSSHion)

A severe vulnerability in OpenSSH, dubbed "regreSSHion" (CVE-2024-6387), has been discovered by the Qualys Threat Research Unit. This flaw allows for remote unauthenticated code execution on affected systems, posing a significant security risk to millions of servers worldwide

Analysis

Understanding the Vulnerability

CVE-2024-6387 is a signal handler race condition in OpenSSH's server (sshd) that affects glibc-based Linux systems. It enables attackers to execute arbitrary code with root privileges without authentication. This vulnerability is particularly concerning as it affects the default configuration of OpenSSH and requires no user interaction.

It occurs during the authentication grace period, which is set by default to 120 seconds.

Source: Qualys Threat Research Unit (TRU) - Link

Scope and Impact

Over 14 million potentially vulnerable OpenSSH instances are directly accessible from the internet, according to searches conducted using Shodan and Censys

Detailed Analysis

The regression was introduced in October 2020 by commit 752250c, which inadvertently removed an #ifdef DO_LOG_SAFE_IN_SIGHAND from the sigdie() function. This removal reintroduced the signal handler race condition, making sshd vulnerable once again. The issue arises from the use of async-signal-unsafe functions like syslog() within the SIGALRM handler.

The use of async-signal-unsafe functions like syslog() within a SIGALRM handler is generally not recommended and can lead to potential issues.

Async-signal-unsafe functions: These are functions that are not safe to call from within a signal handler because they may use or modify global data structures or perform operations that could be interrupted by signals.

SIGALRM handler: This is a signal handler for the SIGALRM signal, which is typically used for timer-based operations.

Problems with using syslog() in a SIGALRM handler: 

Exploitation Process

The exploit takes advantage of the following sequence: 


The exploit involves three key problems:

Researchers tested the exploit on various OpenSSH versions:


Link to the Full POC - regresshion.txt

Affected Systems

The vulnerability primarily affects Linux systems using glibc. Other Unix-like operating systems such as FreeBSD, OpenBSD, and macOS are not vulnerable to this specific exploit

Detection

Organizations can identify vulnerable systems by verifying the installed version of the OpenSSH server. Qualys has released a detection QID (42046) to help identify affected systems. However, accurate detection requires root privileges, as the command used only runs with root access.

Detection opportunity

Mitigations

Stratergies

Conclusion

CVE-2024-6387 represents a critical security threat to OpenSSH servers. Organizations should prioritize patching and mitigation efforts to protect their systems from potential exploitation. Regular security assessments and prompt application of security updates remain crucial in maintaining a robust cybersecurity posture.

By staying informed about such vulnerabilities and taking swift action, organizations can significantly reduce their exposure to cyber risks and protect their valuable assets and data.

I will be publishing a detailed POC in some time. Stay Tuned.

Acknowledgments 

We extend our gratitude to the OpenSSH developers for their ongoing efforts in maintaining secure software and to the security researchers who uncovered this vulnerability. For further technical details, refer to the research paper by Michal Zalewski and the relevant bug reports on OpenSSH's Bugzilla.

Sources/References