Vulnerabilities

7 min readUpdated

CVE-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 portableStatusReason
< 4.4p1VulnerableOriginal CVE-2006-5051, unless back-patched for it and for CVE-2008-4109
4.4p1 – 8.4p1Not vulnerableThe 2006 fix neutralised the handler
8.5p1 – 9.7p1VulnerableThe 2020 logging rewrite removed the guard
9.8p1 and laterFixedUnsafe 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.

Version and package checks (Debian/Ubuntu and RHEL families)
# 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.

PlatformFixed packageAdvisory
OpenSSH upstream9.8p1openssh.com release-9.8
Debian 12 (bookworm)1:9.2p1-2+deb12u3DSA-5724-1
Ubuntu 24.04 LTS (noble)1:9.6p1-3ubuntu13.3USN-6859-1
Ubuntu 22.04 LTS (jammy)1:8.9p1-3ubuntu0.10USN-6859-1
RHEL 9openssh-8.7p1-38.el9_4.1RHSA-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
Config mitigation and a source allow-list (checked with sshd -t and nft -c on Debian 12)
# 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.

DateEvent
19 May 2024Qualys notifies the OpenSSH developers
20 June 2024Distributions notified via the distros@openwall list
1 July 2024Coordinated disclosure; OpenSSH 9.8p1 and distro fixes released
8 July 2024CVE-2024-6409 disclosed as a related child-process race

Questions

Frequently asked questions

It is not listed in CISA's Known Exploited Vulnerabilities catalogue, and exploitation is difficult. The Qualys demonstration needed 6–8 hours of continuous connections against a 32-bit target, and 64-bit exploitation was considered possible but was not shown. Treat it as a serious bug to patch promptly rather than a one-shot remote exploit, and reduce SSH exposure to limit opportunistic attempts.

Not necessarily. Distributions back-port fixes without changing the leading version, so a Debian 12 box can report 9.2p1 yet run the patched package 1:9.2p1-2+deb12u3. Check the full package version with dpkg-query or rpm, and make sure the service was restarted after the upgrade.

It closes the remote code execution path by removing the timeout whose expiry fires the unsafe signal handler, and it also covers the related CVE-2024-6409. The cost is that sshd can no longer time out stalled unauthenticated connections, so an attacker can exhaust MaxStartups and cause a denial of service. Patching is better.

A web application firewall cannot, because SSH is not HTTP traffic and never passes through it. A network firewall helps a great deal by restricting which addresses may reach port 22. The durable answer is to install the patched OpenSSH package and restrict SSH to trusted networks.

Both are signal-handling races in sshd. CVE-2024-6387 affects the privileged listener on glibc Linux and can lead to root. CVE-2024-6409 affects the lower-privileged child process, mainly on Red Hat-family builds of OpenSSH 8.7p1 and 8.8p1 with the audit patch, so its impact is lower. LoginGraceTime 0 mitigates both.

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.

  1. 01NVD — CVE-2024-6387 · NVD
  2. 02regreSSHion: RCE in OpenSSH's server (advisory) · Qualys
  3. 03regreSSHion: Remote Unauthenticated Code Execution Vulnerability in OpenSSH server · Qualys
  4. 04CVE-2024-6387 (mitigation and affected RHEL releases) · Red Hat
  5. 05RHSA-2024:4312 openssh security update · Red Hat
  6. 06OpenSSH 9.8 release notes · OpenSSH
  7. 07Fix commit 81c1099 · openssh-portable
  8. 08DSA-5724-1 / CVE-2024-6387 tracker · Debian
  9. 09CVE-2024-6387 (Ubuntu) · Canonical
  10. 10CVE-2024-6409 disclosure · oss-security

Last updated