Guides / Famous CVEs

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

intermediateUpdated 26 Nov 2026940 words

On 2024-07-01 Qualys published regreSSHion, a remote code execution in the OpenSSH server that does not need 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. The bug was an old one: a fix 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): network, no privileges, but 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, in plain terms

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 reported that winning the race took about 10,000 tries on average. Against a 32-bit Debian 12.5 test machine, with sshd accepting 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 them 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.

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

It is not on the CISA KEV list as of November 2026. Its EPSS score on 2026-11-25 was 0.61, in the top 1 % of all CVEs.

How to check a server today

Check the installed package against 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.

After an update, the listening sshd must be restarted to load the new binary. The Debian and Ubuntu packages do this on upgrade. When in doubt, restart it; 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

With no timeout, the vulnerable signal handler never runs. In return, unauthenticated connections are never dropped, so an attacker can fill all MaxStartups slots and lock out new logins. Use it only until the package update is in.

Restricting SSH to known addresses, a VPN or a bastion host also removes the remote attack path, and is worth doing anyway.

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. Because that commit was part of a large change, distributions backported smaller patches. Debian, for example, disabled the unsafe code in the sshsigdie() function.

What to take from it

  • Regressions happen in old, reviewed code. A test for the original 2006 fix would have caught the 2020 change.
  • High attack complexity is still a reason to patch. Hours of connections are cheap for an automated attacker.
  • SSH does not need to face the whole internet. Firewall rules or a VPN shrink the attack surface for every future sshd bug too.
  • Read version strings the distribution way. Scanners that compare upstream versions flag patched Debian and Ubuntu servers; see backports and version numbers.

Sources

Check your servers every day

The agent of Patchbrief reports the packages and settings of a server once a day; the digest names what to fix first.

Start free