Sphere
Log in Join

Patching CVE-2024-6387 regreSSHion on Ubuntu 22.04 OpenSSH 8.9

## How I found out

Monday morning, a mailing-list post about CVE-2024-6387, an unauthenticated RCE in sshd caused by a signal handler race in the pre-auth path. It affects OpenSSH 8.5p1 through 9.7p1. Our small fleet is Ubuntu 22.04, which ships 8.9p1, so yes, we were exposed:

$ sshd -V
OpenSSH_8.9p1 Ubuntu-3ubuntu0.6, OpenSSL 3.0.2 15 Mar 2022

Two of these boxes have SSH on the public internet. Not my decision, but my problem. The bug is nasty because it needs no account and no user interaction; you just connect in a particular way and race the SIGALRM handler. Upstream's write-up calls out that syslog() is not async-signal-safe, which is the root of it.

## The fix that actually exists

Ubuntu shipped 1:8.9p1-3ubuntu0.10 with the upstream patch. Do not go compiling OpenSSH from source on production machines at 9am unless you enjoy that sort of thing:

apt-get update
apt-get install --only-upgrade openssh-server
sshd -V
OpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022

Verify with dpkg -l openssh-server and check the version string shows ubuntu0.10 or later. On 24.04 the fixed version is different, so check rather than copying my command blindly. I swept all fourteen hosts with a single loop and logged the version before and after, because I wanted a record of what was actually running. I also checked the CVE tracker rather than trusting the mailing list alone, since Ubuntu sometimes backports with a version string that does not match upstream. That is how I caught a fourth host running 9.6p1 from a PPA, which was outside the 8.9 line and needed its own upgrade path.

## The wrong mitigation I almost shipped

The first search result suggested LoginGraceTime 0 as a workaround. Do not do that. Zero disables the login timeout entirely; it was the mitigation for an old 2006 CVE and it makes unauthenticated connections hang around forever, which is a different kind of pain. If you genuinely cannot patch immediately, LoginGraceTime 10 narrows the race window:

# /etc/ssh/sshd_config
LoginGraceTime 10

That is a mitigation, not a fix. Patch.

## What went wrong with the reload

I almost restarted sshd over SSH in the middle of a deploy. Existing sessions normally survive a restart, but I have been burned by config errors before, so this time I kept a second terminal open and validated first:

sshd -t
systemctl reload ssh

The reload matters. A restart drops anything mid-handshake and made two of our CI checkouts fail when I did it the first time on a staging box. Reload picks up the new binary cleanly for new connections without touching established ones.

## Afterward

I added the version check to our host audit script so we do not drift again:

sshd -V 2>&1 | grep -q 'Ubuntu-3ubuntu0.1[0-9]' || echo "CHECK SSH BUILD"

Rough around the edges but it caught one box we had missed. I also finally put those two public-facing hosts behind a VPN, which is where they should have been all along. The patch was the easy part; the process around it was the annoying bit.