CVE-2024-6387, dubbed ‘regreSSHion’ by Qualys researchers who discovered it, is a critical unauthenticated remote code execution (RCE) vulnerability in OpenSSH’s server (sshd). Disclosed in July 2024, it affects OpenSSH versions before 4.4p1 (without backported patches) and versions 8.5p1 through 9.7p1 — a range that exposed an estimated 14 million internet-facing OpenSSH instances. This article provides a technical analysis of the vulnerability, its exploitation, and mitigation steps.
Vulnerability Overview
CVE ID: CVE-2024-6387
CVSS 3.1: 8.1 (High) — AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
Affected: glibc-based Linux systems running OpenSSH 8.5p1-9.7p1
and OpenSSH < 4.4p1 (without CVE-2006-5051 patch)
Fixed in: OpenSSH 9.8p1
Type: Race condition in signal handler (async-signal-safety violation)
Discoverer: Qualys Threat Research Unit
Published: July 1, 2024Technical Analysis: The Race Condition
The vulnerability is a regression of CVE-2006-5051, an async-signal-safety vulnerability that was fixed in 2006 but inadvertently reintroduced in OpenSSH 8.5p1 (released October 2020).
The root cause: sshd’s SIGALRM handler calls syslog(), which is not async-signal-safe. When a client fails to authenticate within the LoginGraceTime (default: 120 seconds), sshd sends itself a SIGALRM. If this signal arrives at a critical moment during malloc()/free() operations in the main process, the resulting heap corruption can be leveraged for RCE.
Attack flow:
1. Attacker opens TCP connection to sshd (port 22)
2. Attacker does NOT send SSH client identifier (holds connection open)
3. After LoginGraceTime (120 seconds), sshd's alarm fires
4. SIGALRM handler calls syslog() — ASYNC-SIGNAL-UNSAFE
5. If the race condition is won, heap metadata is corrupted
6. Corrupted heap enables arbitrary code execution as root
Key challenge: Exploit is timing-dependent and architecture-specific
- Requires precise heap manipulation
- Race window is narrow (microseconds)
- Practical exploitation requires 6-8 hours of continuous attempts
against glibc-based x86-64 Linux
- OpenBSD and Alpine Linux (musl libc) are NOT vulnerable
- 32-bit systems theoretically exploitable but not demonstrated publiclyWhat Makes regreSSHion Particularly Dangerous
1. Pre-authentication: No credentials needed to trigger
2. Root RCE: sshd runs as root by default
3. ASLR bypass: Practical exploitation works despite ASLR on 32-bit
(32-bit address space exhausted in ~6-8 hours)
4. Scale: 14 million internet-facing instances identified by Qualys
5. Minimal logging: Failed attempts don't generate unusual log entriesAffected Versions
VULNERABLE:
- OpenSSH < 4.4p1 (old, without CVE-2006-5051 patch)
- OpenSSH 8.5p1 through 9.7p1 (regression reintroduced)
NOT VULNERABLE:
- OpenSSH 4.4p1 through 8.4p1 (original fix in place)
- OpenSSH 9.8p1 and later (patched)
- OpenBSD (different signal handling)
- Alpine Linux (musl libc, different heap implementation)
# Check your version
ssh -V
# or
sshl -V # Debian/Ubuntu may show different outputChecking for Vulnerability
# Check OpenSSH version
sshd -V
ssh -V
# Check if sshd is running and its version
ps aux | grep sshd
sshd -t -f /etc/ssh/sshd_config 2>&1
# Remote check with nmap
nmap -p 22 --script ssh-auth-methods TARGET
nmap -p 22 -sV TARGET # Shows OpenSSH version
# Mass scanning with nuclei
nuclei -t ~/nuclei-templates/cves/2024/CVE-2024-6387.yaml -l targets.txt
# Check LoginGraceTime (increases attack difficulty if lowered)
grep LoginGraceTime /etc/ssh/sshd_configProof of Concept Availability
Qualys released a technical blog post but responsibly withheld a working exploit at disclosure. Within days, partial PoC scripts appeared on GitHub demonstrating the race condition, though fully reliable exploitation remains complex. The key challenge is winning the race condition reliably — the original Qualys research reported approximately 1 in 10,000 connection attempts wins the race on x86-64.
By August 2024, threat intelligence reports indicated active scanning for vulnerable sshd versions, though mass exploitation requires significant computational resources and time.
Mitigation and Remediation
PRIMARY FIX: Upgrade OpenSSH to 9.8p1 or later
# Debian/Ubuntu
apt update && apt install --only-upgrade openssh-server
# Red Hat/CentOS (check vendor-specific patches)
yum update openssh-server
# or
dnf update openssh-server
# Verify fixed version
sshd -V # Should show OpenSSH_9.8p1 or later
TEMPORARY MITIGATION (if immediate upgrade not possible):
# Set LoginGraceTime to 0 in /etc/ssh/sshd_config
# This disables the SIGALRM mechanism entirely
echo 'LoginGraceTime 0' >> /etc/ssh/sshd_config
systemctl restart sshd
# WARNING: LoginGraceTime 0 means incomplete authentication
# attempts don't get cleaned up - potential DoS risk on heavily
# connection-flooded servers. Monitor connection counts.
ADDITIONAL HARDENING:
# Rate limit SSH connections with iptables
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 10 -j DROP
# Or use fail2ban
apt install fail2ban
# /etc/fail2ban/jail.local: maxretry = 3, bantime = 3600Detection
# Exploitation leaves evidence in auth.log / secure
grep 'Did not receive identification string' /var/log/auth.log
# Large numbers of this message = potential exploitation attempt
# Many connections without completing auth
ss -tn | grep ':22' | wc -l
# High numbers of ESTABLISHED connections to :22
# SIEM rule: Alert on 100+ connections to port 22 within 60 seconds
# from same source IP without successful authenticationImpact Assessment
Successful exploitation of CVE-2024-6387 provides unauthenticated root RCE on the target system. This enables complete system compromise: data theft, ransomware deployment, persistent backdoors, lateral movement, and use as a pivot point. The long exploitation time (6-8 hours continuous attempts) limits opportunistic mass exploitation but does not protect against targeted, determined attackers with time and resources.
Conclusion
CVE-2024-6387 regreSSHion represents a critical regression in one of the most widely deployed services on the internet. While practical exploitation is technically demanding due to the race condition requirement, the pre-authentication nature and root RCE capability make it a severe risk. Immediate patching to OpenSSH 9.8p1 is the definitive fix. Organizations unable to patch immediately should set LoginGraceTime 0 and implement connection rate limiting as temporary mitigations.