Guides / Famous CVEs

regreSSHion (CVE-2024-6387): the OpenSSH race condition

intermediateUpdated 26 Nov 2026885 words

On 2024-07-01 Qualys published regreSSHion, a remote code execution in the OpenSSH server that works without an account or a password. It affected sshd in its default configuration on glibc-based Linux with OpenSSH 8.5p1 to 9.7p1, the versions released from 2021 on. A fix for the same bug from 2006 had been removed by accident in 2020.

What broke

sshd gives a client LoginGraceTime seconds (120 by default) to authenticate. When the time is up, a SIGALRM signal handler ends the connection. A signal handler can interrupt the program at any point, so it may only call functions that are safe in that situation. The handler in sshd logged a message with syslog(), and on glibc syslog() can call malloc() and free(). If the signal arrives while sshd itself is inside malloc() or free(), the heap is left in an inconsistent state that an attacker can shape.

This was CVE-2006-5051, fixed in OpenSSH 4.4p1 in 2006. In October 2020 a rewrite of the logging code (commit 752250c, released in OpenSSH 8.5p1) removed the #ifdef that made the handler safe.

Affected versions

From the Qualys advisory:

OpenSSH version Status
before 4.4p1 vulnerable, unless patched for CVE-2006-5051 and CVE-2008-4109
4.4p1 to before 8.5p1 not vulnerable
8.5p1 to before 9.8p1 vulnerable

It is exploitable on Linux with glibc. Qualys did not investigate other C libraries and notes that OpenBSD is not vulnerable. The CVE record rates it 8.1 (AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H): over the network and without privileges, with high attack complexity.

Distribution packages carry the fix under their own version numbers:

Release Shipped Fixed package
Debian 11 8.4p1 not affected
Debian 12 9.2p1 1:9.2p1-2+deb12u3 (DSA-5724-1)
Ubuntu 22.04 8.9p1 1:8.9p1-3ubuntu0.10 (USN-6859-1)
Ubuntu 24.04 9.6p1 1:9.6p1-3ubuntu13.3 (USN-6859-1)
RHEL 9 8.7p1 openssh-8.7p1-38.el9_4.1

How the attack worked

The attacker opens connections and lets each one run into the login timeout, timing its packets so that the timeout fires while sshd is in the middle of heap work. Most attempts fail: Qualys needed about 10,000 tries on average to win the race. Against a 32-bit Debian 12.5 test machine that accepted 100 unauthenticated connections (MaxStartups) per 120 seconds, that meant about 3 to 4 hours to win once, and 6 to 8 hours on average for a root shell, because address randomization made the attack guess right only half the time. At the time of the advisory Qualys was still working on a 64-bit exploit, which is harder because of stronger address randomization. For an automated attacker, a few hours of connections cost little, so the high attack complexity is no reason to wait with the update.

The code runs in the privileged part of sshd, which is not sandboxed. The result is root.

The CVE is not on the CISA KEV list (catalog of 2026-11-25). Its EPSS score on 2026-11-25 was 0.61, in the top 1 % of all CVEs.

How to check a server

Compare the installed package with the table above or the tracker of your distribution:

dpkg-query -W openssh-server   # Debian, Ubuntu
rpm -q openssh-server          # RHEL family

The SSH banner shows the same version, including the Debian revision. Read it from the server itself:

timeout 3 bash -c 'exec 3<>/dev/tcp/127.0.0.1/22; head -1 <&3'
SSH-2.0-OpenSSH_9.2p1 Debian-2+deb12u10

deb12u10 is newer than deb12u3, so this Debian 12 server is fixed. A banner of OpenSSH_9.2p1 Debian-2+deb12u2, the version Qualys exploited, is not. Scanners that compare only the upstream version (9.2p1) flag patched Debian and Ubuntu servers; see backports and version numbers.

The listening sshd loads the new binary only after a restart. The Debian and Ubuntu packages restart it on upgrade; elsewhere, restart it yourself (open sessions stay connected):

sudo systemctl restart ssh     # sshd on RHEL family

The mitigation, if you cannot update

Set LoginGraceTime 0 in /etc/ssh/sshd_config and reload sshd:

echo 'LoginGraceTime 0' | sudo tee /etc/ssh/sshd_config.d/50-logingracetime.conf
sudo sshd -t && sudo systemctl reload ssh     # sshd on RHEL family
sudo sshd -T | grep -i logingracetime

Without a timeout, the vulnerable signal handler never runs. sshd then never drops unauthenticated connections either, so an attacker can fill all MaxStartups slots and lock out new logins. Use it only until the package update is in.

Allowing SSH only from known addresses, a VPN or a bastion host also removes the remote attack path, for this bug and for the next sshd bug.

How it was fixed

OpenSSH fixed it on 2024-06-06 (commit 81c1099), which moved the unsafe code out of the signal handler, and released 9.8p1 with the fix on 2024-07-01. The commit was part of a large change, so distributions backported smaller patches. Debian, for example, disabled the unsafe code in the sshsigdie() function.

Sources

Check your servers every day

The Vulnpocalypse collector reports the packages and settings of a server once a day, and the digest lists what to fix, most urgent first.

Start free