Vulnerabilities
7 min readUpdatedCVE-2024-6387 (regreSSHion): the OpenSSH signal-handler race
Quick answer
CVE-2024-6387, nicknamed regreSSHion, is an unauthenticated remote code execution flaw in OpenSSH's server (sshd) on glibc-based Linux. A signal-handler race lets a client that never finishes authenticating within LoginGraceTime trigger unsafe code, in the worst case gaining root. It affects portable OpenSSH from 8.5p1 up to but not including 9.8p1, disclosed by Qualys on 1 July 2024. It is a regression of a 2006 bug. Exploitation is slow and shown only on 32-bit systems, but patch promptly.
At a glance
high severity- Identifier
- CVE-2024-6387
- Also known as
- regreSSHion
- Product
- OpenSSH portable server (sshd) on glibc-based Linux
- Affected
- 8.5p1 ≤ OpenSSH < 9.8p1; OpenSSH < 4.4p1 if not back-patched against CVE-2006-5051 and CVE-2008-4109
- Fixed in
- OpenSSH 9.8/9.8p1 (1 July 2024); distribution back-ports (see below)
- CVSS
- 8.1 (CVSS 3.1, NVD and Red Hat)
- Disclosed
- Known exploited (CISA KEV)
- Not listed
Patched. Qualys demonstrated remote root against 32-bit glibc systems in about 6–8 hours on average; 64-bit exploitation was not shown. Not in CISA KEV.
01What is CVE-2024-6387?
CVE-2024-6387 is a signal-handler race condition in OpenSSH's server. If a client opens a connection and does not complete authentication within LoginGraceTime (120 seconds by default), sshd raises SIGALRM and runs its handler asynchronously. That handler reaches code that is not async-signal-safe — for example syslog(), which on glibc calls malloc() and free(). Interrupting the main thread at the wrong moment can leave the heap inconsistent, and an attacker who wins that race can, in the worst case, run code as root.
Qualys, who found and named it regreSSHion, established that it is a regression of CVE-2006-5051 from 2006. A 2020 logging rewrite in OpenSSH 8.5p1 accidentally dropped the guard that had made the handler safe, reopening a bug that had been closed for fourteen years. OpenBSD is not affected, because its handler uses an async-signal-safe logging path.
02Which versions are affected?
Exposure is a window, not a cut-off. Very old releases are vulnerable, a long middle band is safe, and the recent band before the fix is vulnerable again.
| OpenSSH portable | Status | Reason |
|---|---|---|
| < 4.4p1 | Vulnerable | Original CVE-2006-5051, unless back-patched for it and for CVE-2008-4109 |
| 4.4p1 – 8.4p1 | Not vulnerable | The 2006 fix neutralised the handler |
| 8.5p1 – 9.7p1 | Vulnerable | The 2020 logging rewrite removed the guard |
| 9.8p1 and later | Fixed | Unsafe code moved out of the signal handler |
03How does an attack work, conceptually?
The attacker opens many connections and simply waits, never authenticating, so that each one's LoginGraceTime expires and fires SIGALRM. The goal is to have the alarm land precisely while sshd is inside a memory operation, leaving allocator state that the handler then corrupts. It is a probabilistic race: Qualys reported roughly 10,000 attempts on average to win it.
That difficulty is the whole story of this bug's real-world risk. A working demonstration needed 6–8 hours of continuous connections against a 32-bit target with ASLR, and exploitation on 64-bit systems was believed possible but not shown. There is no single magic packet. What a defender should take from this is that limiting how fast an attacker can open unauthenticated connections directly lengthens the time an attack needs.
04How to check if you are affected
Read the banner version and the installed package version. The upstream version alone can mislead you, because distributions back-port the fix without changing the leading number — a Debian box can report 9.2p1 and still be patched.
# Upstream version string
ssh -V # e.g. OpenSSH_9.2p1 Debian-2+deb12u10 ...
sshd -V 2>&1 | head -1
# The package build is what tells you whether the fix is in
dpkg-query -W -f='${Package} ${Version}\n' openssh-server # Debian/Ubuntu
rpm -q openssh-server # RHEL/Fedora/SUSE
# Confirm the running daemon was restarted after the upgrade
systemctl status ssh 2>/dev/null || systemctl status sshd
# Detection: count pre-auth timeouts in the last hour (unit is sshd on RHEL)
journalctl -u ssh --since "-1h" -o cat | grep -c 'Timeout before authentication'05How to fix it: patched versions
Upstream fixed the race in OpenSSH 9.8/9.8p1 on 1 July 2024 by moving the unsafe work out of the signal handler and into the listener process. Distributions shipped back-ports the same day or shortly after. Install the vendor update for your platform and restart the service.
| Platform | Fixed package | Advisory |
|---|---|---|
| OpenSSH upstream | 9.8p1 | openssh.com release-9.8 |
| Debian 12 (bookworm) | 1:9.2p1-2+deb12u3 | DSA-5724-1 |
| Ubuntu 24.04 LTS (noble) | 1:9.6p1-3ubuntu13.3 | USN-6859-1 |
| Ubuntu 22.04 LTS (jammy) | 1:8.9p1-3ubuntu0.10 | USN-6859-1 |
| RHEL 9 | openssh-8.7p1-38.el9_4.1 | RHSA-2024:4312 |
06Mitigations if you cannot patch yet
If you genuinely cannot update immediately, Qualys and Red Hat documented a configuration mitigation: set LoginGraceTime to 0. This removes the timeout whose expiry fires the dangerous signal, closing the remote-code-execution path. The trade-off is explicit — with no grace timeout, an attacker can hold all MaxStartups slots open and cause a denial of service instead. You are trading a possible remote root for a possible lockout.
The more durable mitigation is to stop exposing SSH to the whole internet, as set out in hardening port 22. Most servers have no reason to accept SSH from arbitrary addresses, and reducing exposure shrinks both this bug's surface and the brute-force noise that comes with it. Pair that with sensible connection limits so an attacker cannot open unauthenticated sessions quickly, which is exactly what this race needs.
- Restrict SSH to a management network, VPN or a short allow-list of addresses rather than the public internet
- Lower MaxStartups and PerSourceMaxStartups so unauthenticated connections cannot be opened in bulk
- Watch the auth log for the "Timeout before authentication" message spiking from many sources
- Run a log-watching tool such as fail2ban alongside a host firewall, as Red Hat suggests with the config mitigation
# 1) /etc/ssh/sshd_config.d/10-cve-2024-6387.conf (check: sshd -t)
# Trade-off: removes the RCE path but allows a MaxStartups DoS.
LoginGraceTime 0
MaxStartups 10:30:60
PerSourceMaxStartups 3
# 2) ssh-allowlist.nft: only named admin ranges may reach port 22.
# Check with: nft -c -f ssh-allowlist.nft Load with: nft -f ssh-allowlist.nft
# IPv6 clients are dropped too unless you add an ipv6_addr set.
table inet ssh_allowlist {
set admin_v4 {
type ipv4_addr; flags interval;
elements = { 198.51.100.0/24, 203.0.113.10 }
}
chain input {
type filter hook input priority filter - 10; policy accept;
tcp dport 22 ip saddr @admin_v4 accept
tcp dport 22 drop
}
}07What a reverse proxy or WAF can and cannot do
Be honest about this one: SSH is not HTTP, so a web application firewall does nothing for it. A reverse proxy that terminates HTTP, and the WAF in front of it, protect your website and APIs — they never see the SSH port, and CVE-2024-6387 lives entirely in sshd. No edge rule can filter this, so virtual patching has nothing to offer here.
What edge infrastructure does help with is keeping your origin's real address out of public view. If your website sits behind a proxy and your origin IP is hidden, an attacker targeting your site cannot easily map it to the server behind it. Internet-wide scanners sweep every IPv4 address regardless, though, so an sshd listening on the open internet will still be found — which is why the firewall allow-list above matters more, and why none of this substitutes for installing the patch.
08Disclosure timeline
For scale, Qualys counted over 14 million potentially vulnerable OpenSSH servers exposed to the internet using Censys and Shodan, and about 700,000 vulnerable internet-facing instances — 31% of internet-facing OpenSSH — in its own customer base. The inventory you would build when preparing to stop a DDoS attack, listing every service reachable from the internet, is also the quickest way to confirm nothing exposes SSH that should not.
| Date | Event |
|---|---|
| 19 May 2024 | Qualys notifies the OpenSSH developers |
| 20 June 2024 | Distributions notified via the distros@openwall list |
| 1 July 2024 | Coordinated disclosure; OpenSSH 9.8p1 and distro fixes released |
| 8 July 2024 | CVE-2024-6409 disclosed as a related child-process race |
Questions
Frequently asked questions
Sources
Sources and verification
sshd_config mitigation syntax-checked with sshd -t and resolved with sshd -T (OpenSSH 9.2p1); nftables allow-list checked with nft -c (nftables 1.0.6) in an isolated network namespace; version, package and journalctl commands run with systemd 252; Debian 12, October 2026. rpm was not available on the test host.
- 01NVD — CVE-2024-6387 · NVD
- 02regreSSHion: RCE in OpenSSH's server (advisory) · Qualys
- 03regreSSHion: Remote Unauthenticated Code Execution Vulnerability in OpenSSH server · Qualys
- 04CVE-2024-6387 (mitigation and affected RHEL releases) · Red Hat
- 05RHSA-2024:4312 openssh security update · Red Hat
- 06OpenSSH 9.8 release notes · OpenSSH
- 07Fix commit 81c1099 · openssh-portable
- 08DSA-5724-1 / CVE-2024-6387 tracker · Debian
- 09CVE-2024-6387 (Ubuntu) · Canonical
- 10CVE-2024-6409 disclosure · oss-security
Last updated