
regreSSHion: CVE-2024-6387 - A Critical Vulnerability in OpenSSH
Publication date: 2024-07-03
Introduction
On July 1, 2024, security professionals from Qualys disclosed a critical vulnerability in OpenSSH, designated as CVE-2024-6387, also known as "regreSSHion." This flaw impacts OpenSSH versions from 8.5p1 to 9.8p1, allowing remote code execution with root privileges on both servers and user PCs that use the Glibc standard library. The implications are vast, given the widespread use of OpenSSH in Unix-like and Linux systems worldwide. This article delves into the nature of this vulnerability, methods to detect vulnerable systems, and steps for mitigation.
Understanding CVE-2024-6387
The Vulnerability
CVE-2024-6387 arises from a race condition in the signal handling code of OpenSSH's server (sshd). This flaw is a regression of an older vulnerability (CVE-2006-5051) that was inadvertently reintroduced in OpenSSH 8.5p1 during changes to the logging infrastructure. The issue lies in the unsafe use of functions like syslog()
in the SIGALRM handler, which can be interrupted by the signal, leading to memory corruption and allowing arbitrary code execution.
Technical Details
The vulnerability exploits a race condition triggered by the SIGALRM signal, which is used in OpenSSH to handle login timeouts. When the login grace time expires, the SIGALRM handler calls syslog()
, a function not designed for asynchronous use, leading to potential memory state violations. Attackers can manipulate this to execute arbitrary code with root privileges.
Detecting Vulnerable Systems
Identifying Affected Versions
To determine if your systems are vulnerable, check the OpenSSH version installed. The affected versions are:
- Vulnerable: OpenSSH 8.5p1 to 9.8p1
- Not Vulnerable: Versions before 4.4p1 and from 4.4p1 to 8.5p1
Detection Steps
Step 1: Check the Installed OpenSSH Version
Run the following command to check the installed version of OpenSSH:
ssh -V
This will output the OpenSSH version installed on your system, such as:
OpenSSH_8.4p1 Debian-5, OpenSSL 1.1.1d 10 Sep 2019
Step 2: Determine Vulnerability
Compare the version number from the output with the vulnerable range. Versions between 8.5p1 and 9.8p1 are vulnerable. If your version is within this range, your system is vulnerable.
Step 3: List Installed OpenSSH Packages
You can also list the installed OpenSSH packages to verify their versions:
dpkg -l | grep openssh
This command will list all installed OpenSSH packages and their versions, such as:
ii openssh-client 1:8.4p1-5 amd64 secure shell (SSH) client, for secure access to remote machines ii openssh-server 1:8.4p1-5 amd64 secure shell (SSH) server, for secure access from remote machines
Mitigation Strategies
Immediate Actions
Upgrade OpenSSH
Update your package list and upgrade OpenSSH to the latest version:
sudo apt update & sudo apt install openssh-server
Ensure the version installed is 9.8p1 or later.
Modify SSH Configuration as a Temporary Workaround
While waiting for an upgrade, you can modify the sshd_config
file to reduce the risk:
-
Set
LoginGraceTime
to 0:Open the SSH configuration file:
sudo nano /etc/ssh/sshd_config
Find the
LoginGraceTime
directive and set it to 0:LoginGraceTime 0
Save and close the file.
Conclusion
CVE-2024-6387, or regreSSHion, poses a significant threat to systems running vulnerable versions of OpenSSH. While the complexity of the exploit means that successful attacks require high skill and persistence, the potential for root-level access necessitates immediate action. By upgrading to the latest OpenSSH version and implementing robust security measures, organizations can protect their infrastructure from this critical vulnerability. Stay vigilant, keep your systems updated, and employ a multi-layered defense strategy to mitigate risks effectively.