On 1 July 2024 the OpenSSH project released version 9.8 with a one-paragraph security note: a race condition in sshd could allow unauthenticated remote code execution as root, on every portable OpenSSH from 8.5p1 to 9.7p1. The bug had a name before the day was out — regreSSHion, coined by the Qualys researchers who found it — because it was not new. It was the return of a flaw first reported and fixed in 2006, reintroduced by a logging refactor in October 2020 and shipped, unnoticed, in every OpenSSH release for the next three and a half years. It was never exploited in the wild as far as anyone has shown, it was fiendishly hard to exploit even in a lab, and it was treated as an emergency by almost everyone running a Linux server. This page is about why all three of those things were true at once.
This is the third page in a series on the vulnerabilities that changed how Linux is built and defended, after Heartbleed and Shellshock. Each tells the story from the project’s own records, says what it taught, and ends with what to check on your machine today.
What happened
The story starts in 2006. Mark Dowd reported that if an SSH client connected and then failed to authenticate before the login grace period expired, the alarm signal that ended the attempt ran a handler that called syslog() — and syslog() is not safe to call from a signal handler. OpenSSH 4.4p1 fixed it (CVE-2006-5051) by making the handler do nothing but exit, and in 2008 a second identifier (CVE-2008-4109) was issued for distributions whose backport of the fix had been incomplete. For the next fourteen years, from 4.4p1 to 8.4p1, the handler was safe.
On 16 October 2020 a commit titled “revised log infrastructure for OpenSSH” reorganised how the daemon logged. In the course of it, a preprocessor guard that had kept the logging call out of the signal path — DO_LOG_SAFE_IN_SIGHAND — was removed from the exit-on-signal function. Nothing broke, no test failed, and the change shipped in OpenSSH 8.5p1 in March 2021. Every portable release from then until 9.7p1 inherited it. On 19 May 2024 Qualys contacted the OpenSSH developers; on 20 June the distributions were told; on 1 July OpenSSH 9.8 and the distribution updates went out together. The upstream fix, committed on 6 June, moved the unsafe work out of the signal handler altogether and into the listener process, where it could be done synchronously — as part of a larger change that also introduced PerSourcePenalties, sshd’s new defence against clients that repeatedly misbehave. For distributions carrying older code, that commit was too large to backport, so most shipped a one-line patch instead: the signal path no longer logs. Ubuntu’s was prepared on 26 June and held for the coordinated date.
The affected range produced an unusual map. Ubuntu 22.04 (OpenSSH 8.9p1), 23.10 and 24.04 (9.6p1) needed the update; Ubuntu 20.04, on 8.2p1, did not. Debian 12 (9.2p1) was affected; Debian 11, on 8.4p1, was not. RHEL 9, on 8.7p1, was the only Red Hat release affected; RHEL 8 and everything before it had never had the code. For once, the older and more conservative your distribution, the safer you were — and OpenBSD, the system OpenSSH is developed on, was never affected at all, because its syslog_r(), a signal-safe variant it had invented in 2001, is what the handler called there.
The flaw, in one paragraph
A signal handler can run between any two instructions of the program it interrupts, so it may only call functions that are safe to run in that position. The C library’s allocator is not one of them: if the main program is halfway through malloc() when the signal arrives and the handler also allocates, the allocator’s bookkeeping is corrupted. syslog() allocates. When an SSH client connected to a vulnerable sshd and simply did not finish logging in within LoginGraceTime — 120 seconds by default — the alarm fired and the handler logged the timeout, with the connection’s child process in whatever state the attacker had managed to leave it. The attacker controls nothing about when the alarm fires relative to the program’s own work, which is why Qualys needed thousands of attempts and many hours against a single 32-bit target, and why 64-bit exploitation was described as believed possible but not demonstrated. The flaw is a textbook one; the exploit is not.
The two settings that bounded the attack, as a current Ubuntu 24.04 sshd reports them:
$ ssh -V
OpenSSH_9.6p1 Ubuntu-3ubuntu13.20, OpenSSL 3.0.13 30 Jan 2024
$ sudo sshd -T | grep -iE '^(logingracetime|maxstartups|persourcepenalties)'
logingracetime 120
maxstartups 10:30:100LoginGraceTime is the clock the race ran on, and setting it to 0 was the published workaround — it disables the alarm, at the cost of letting an attacker hold unauthenticated connections open until MaxStartups (ten, here, before random dropping begins) is exhausted. PerSourcePenalties is missing from the output because this is 9.6p1: the facility arrived in 9.8 with the fix, and on a 9.8-or-later server the same command prints its settings.
Why a nearly unexploitable bug mattered so much
Heartbleed was exploitable by anyone; Shellshock by anyone with curl. regreSSHion was demonstrated only on 32-bit glibc systems, only in virtual machines, only after hours of continuous connection attempts that any intrusion detection would have noticed. Red Hat rated it Important rather than Critical, citing the unpredictable race; its CVSS score of 8.1 carries the “attack complexity: high” flag that keeps it out of the top band. And yet nearly every Linux server on the internet was patched for it within days.
The reason is what sshd is. It is the one service that is on nearly every Linux machine, that listens on the public internet by design, that runs as root by necessity, and that the people who own the machine use to reach it — so it cannot simply be turned off while a fix is awaited. Internet scans at the time found around fourteen million exposed OpenSSH servers running potentially affected versions, and Qualys put the share of internet-facing instances in its own customer base that were vulnerable at nearly a third. An unauthenticated root compromise of that service, however improbable per attempt, is the worst case the system has, and the correct response to a worst case with a known fix is to apply the fix. Most did, within days, and the absence of any confirmed exploitation afterwards is the measure of how well that worked rather than evidence that the alarm was false.
There was also a lesson hiding in the Ubuntu 24.04 package. Qualys found that its sshd children were not being re-randomised: Ubuntu had patched the daemon to work under systemd socket activation, and that patch had turned off the re-execution that gives each connection a fresh address-space layout. The researchers called this “generally a bad idea” — and noted that, in this one case, it happened to make their exploit fail. An accident of packaging had provided a protection that nobody had designed; Canonical shipped the fix anyway, and was right to.
What it taught Linux
A security fix without a test is a fix until the next refactor. The 2006 patch was correct and well understood, and it was undone fourteen years later by a change that had nothing to do with security, made by careful people, in a project with an exceptional record. Nothing in the build or test suite knew the guard mattered. The practical lesson is the one every mature project has since taken on: when a vulnerability is fixed, leave something behind that fails if it comes back — a regression test, an assertion, a comment that says this line is CVE-2006-5051 — because the person who refactors the file in a decade will not be the person who fixed it.
Defence in depth is what you have when the code is wrong. The bug was a genuine remote root hole, and the thing that turned it from a catastrophe into a difficult research result was the layers around it: privilege separation, ASLR, 64-bit address spaces, the rate limits in MaxStartups. None of them was a fix. All of them bought time, and time is what a coordinated disclosure needs. The 9.8 release added another layer in PerSourcePenalties, which slows down exactly the behaviour — repeated failed or abandoned connections from one source — that an attack on a race condition depends on, and that is how OpenSSH chose to answer the class rather than the instance.
Backports are a judgement, not a copy. Upstream’s fix was part of a large commit on top of a larger one; the distributions could not take it without taking a new feature into a stable release, so they wrote a minimal patch that removed the logging call and nothing else. That is the right call and it carries a cost: the stable packages have a different fix from upstream, and the next person to audit them has to understand both. The same tension decided how the 2006 fix was backported, and the 2008 CVE exists because one of those backports got it wrong. The Life of a Package is the page on why a distribution’s version number tells you less than its changelog does.
Port 22 on the internet is a decision. The most durable effect of regreSSHion was not in code. For many administrators it was the prompt to decide that sshd did not need to be reachable from every address on earth — that a VPN, a bastion, an allowlist or a port-knocking rule in front of it was worth the inconvenience — because the next regression in the most trusted daemon on the system will come, and the only question is who can reach it when it does. The fix for this bug took hours to roll out. Reducing who can talk to the service in the first place is the only defence that works before the advisory is written.
What to check on your machine today
The first check is the version; the rest are about the workaround, which outlived the bug on more machines than it should have, and the exposure, which is the part you control.
ssh -V
dpkg -l openssh-server | tail -1 # Debian/Ubuntu: fixed in 1:9.6p1-3ubuntu13.3 (24.04), 1:8.9p1-3ubuntu0.10 (22.04), 1:9.2p1-2+deb12u3 (Debian 12)
rpm -q openssh-server # RHEL 9 and derivatives; RHEL 8 and earlier were never affected
zcat /usr/share/doc/openssh-server/changelog.Debian.gz | grep -m1 -B4 CVE-2024-6387Any OpenSSH older than 8.5p1 or newer than 9.7p1 is outside the affected range; anything inside it is fixed if the package changelog says so, which on the machine used for this page reads openssh (1:9.6p1-3ubuntu13.3) noble-security with the line don't log in sshsigdie() in log.c — the one-line backport — dated 26 June 2024. A version string on its own does not tell you, which is the usual lesson about distribution packages.
sudo sshd -T | grep -iE '^(logingracetime|maxstartups|persourcepenalties)'
grep -rn 'LoginGraceTime' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/ 2>/dev/null
ls /etc/ssh/sshd_config.d/Remove the workaround if you applied it. LoginGraceTime 0 was the published mitigation for a few days in July 2024, and the package update does not remove it — Red Hat’s advisory says so explicitly. A server still carrying it is a server any client can tie up by opening ten connections and saying nothing, which is a worse position than the one the setting was meant to fix. If the first command prints logingracetime 0, find the file that sets it (Ubuntu’s blog suggested /etc/ssh/sshd_config.d/cve-2024-6387.conf) and delete it. On the machine used for this page the drop-in directory is empty and the grace time is the default 120 seconds.
ss -tlnp | grep ':22 ' # which addresses sshd listens on
systemctl is-enabled ssh.socket 2>/dev/null # Ubuntu 24.04: socket-activated sshd
sudo sshd -T | grep -iE '^(permitrootlogin|passwordauthentication|kbdinteractiveauthentication|maxauthtries)'Decide who can reach port 22, and make the rest of the configuration assume they are hostile. The measured defaults here are permitrootlogin without-password, passwordauthentication yes and maxauthtries 6, which is to say a stock server still accepts passwords. Securing a New Linux Server is the page on turning that off, and The Life of an SSH Connection is the page on what the listener, the privilege-separated child and the grace timer actually are, which is the context this whole bug sits in. If ss shows 0.0.0.0:22 on a machine that only you ever log into, the question regreSSHion asked in 2024 is still open on it.
Sources
- OpenSSH 9.8 release notes and Damien Miller’s release announcement to oss-security, 1 July 2024 — the affected range (8.5p1 to 9.7p1 inclusive), the demonstrated-on-32-bit statement, OpenBSD not vulnerable, the credit to Qualys, and the separate ObscureKeystrokeTiming fix in the same release
- Qualys Security Advisory, “regreSSHion: RCE in OpenSSH’s server, on glibc-based Linux systems (CVE-2024-6387)”, oss-security, 1 July 2024 — the 2006 history (CVE-2006-5051, Mark Dowd; CVE-2008-4109), the introducing commit 752250c of October 2020, the fix commit 81c1099 of 6 June 2024, the timeline (19 May, 20 June, 1 July), the
LoginGraceTime 0mitigation and its downside, thesyslog_r()note, and the Ubuntu 24.04 re-randomisation side note. Its exploitation sections are not reproduced here. - Qualys Threat Research blog, 1 July 2024 — the Censys/Shodan figure of over 14 million potentially vulnerable exposed instances and the roughly 700,000 (31 per cent) figure from Qualys’s own customer data
- Ubuntu security tracker CVE-2024-6387 and USN-6859-1, and Canonical’s blog post of 3 July 2024 — fixed versions per release, the “not affected” releases, and the socket-activation note
- Debian security tracker CVE-2024-6387 and DSA-5724-1 — bookworm fixed in 1:9.2p1-2+deb12u3, bullseye not affected (“vulnerable code introduced later”)
- Red Hat CVE-2024-6387 page — Important severity and its reasoning, RHEL 9 as the only affected release, and the note that the
LoginGraceTimeworkaround is not removed by the update - The openssh-server package changelog on Ubuntu 24.04 (1:9.6p1-3ubuntu13.3, 26 June 2024) — read on the machine used for this page
Related reading
- Heartbleed and Shellshock — the first two pages in this series, and the two easy-to-exploit cases this one is the opposite of
- The Life of an SSH Connection — the listener, the per-connection child and the grace timer, stage by stage
- ssh — the server configuration keywords used on this page
- Securing a New Linux Server — keys only, no root login, and who gets to reach port 22
- Keeping a Server Patched — why the fix for this one reached most machines within a day of the advisory
- The Life of a Package — why a distribution’s version string is not the whole story, and the changelog is
- The rest of this series — the privilege-escalation decade, Meltdown and Spectre and the Morris worm — the pages that follow this one

