CVE-2025-62877

regreSSHion (CVE-2024-6387): The Ghost of 2006 Returns for Root

Alon Barad
Alon Barad
Software Engineer

Jan 5, 2026·5 min read

Executive Summary (TL;DR)

OpenSSH's `sshd` has a signal handler race condition. If a client doesn't authenticate within `LoginGraceTime` (default 120s), `SIGALRM` is raised. The handler calls `syslog()`, which is not async-signal-safe. If this interrupts a heap operation (like `free()`) in the main thread, it corrupts the heap. Attackers can win this race to gain unauthenticated root RCE.

A signal handler race condition in OpenSSH's server (sshd) on glibc-based Linux systems allows unauthenticated remote code execution as root. This is a regression of a vulnerability originally fixed in 2006 (CVE-2006-5051), reintroduced via code refactoring.

The Hook: Plumbing of the Internet

OpenSSH is the boring, reliable plumbing that holds the internet together. It's the one port you leave open to the world. So, when a vulnerability drops in OpenSSH, it's not just a bad day; it's a 'cancel your weekend and grab the caffeine' kind of event.

Meet regreSSHion. The name is a pun, but the bug is a tragedy. It is a regression of CVE-2006-5051. That's right—we fixed this bug eighteen years ago. But, like a villain in a slasher movie, it came back because someone decided to refactor the code and accidentally removed the safety rails.

The vulnerability resides in sshd, the server-side daemon. Specifically, it's a classic signal handler race condition affecting glibc-based Linux systems. If you are running OpenSSH versions 8.5p1 through 9.7p1, your front door might just be unlocked.

The Flaw: Sins of the Signal Handler

To understand this bug, you need to understand one cardinal rule of C programming: Async-Signal-Safety.

When a signal (like SIGALRM or SIGINT) hits a process, the OS pauses the main execution thread and jumps to a specific function called a 'signal handler'. This handler runs in a fragile state. The main program could have been paused anywhere—even right in the middle of updating a sensitive data structure.

Because of this, signal handlers are restricted. They should only call functions that are 'async-signal-safe'. These are functions guaranteed not to mess up global state or lock mutexes that might already be held.

Here is where OpenSSH messed up (again):

[!CAUTION] The SIGALRM handler in sshd calls syslog().

syslog() is not async-signal-safe. Internally, syslog() often allocates memory using malloc() or free(). If the signal interrupts the main thread while it is already inside malloc() or free(), and then the handler calls syslog() (which calls malloc/free again), you corrupt the heap metadata. It's like trying to reorganize a library, getting interrupted, and having someone else start reorganizing the same shelf before you finished.

The Code: The Smoking Gun

Let's look at the crime scene. The issue lies in how sshd handles the LoginGraceTime. By default, you have 120 seconds to log in. If you don't, SIGALRM fires.

In the vulnerable code, the signal handler eventually calls sigdie(), which acts as a wrapper for logging an error and exiting.

// The Vulnerable Logic Pattern
void sigdie(const char *fmt, ...)
{
    // ... varargs setup ...
    // FATAL MISTAKE: Calling syslog inside a signal handler
    syslog(LOG_INFO, fmt, args);
    _exit(1);
}

The fix was simple but critical: remove the complex logging from the signal handler context. In the patched versions, the logic is refactored to ensure that the code executing in the handler is strictly safe.

The patch effectively moves the unsafe logic out of the asynchronous context, or ensures the handler simply sets a flag that the main loop checks later, rather than executing complex logic immediately.

[!NOTE] This regression was introduced in OpenSSH 8.5p1 (October 2020) when #ifdef DO_LOG_SAFE_IN_SIGHAND was accidentally removed during a refactor.

The Exploit: Winning the Race

Exploiting this is not a 'point-and-click' adventure. It is a statistical brute-force attack against memory timings.

The attacker connects to sshd and does... nothing. They wait. They want the LoginGraceTime (120s) to expire exactly when the sshd process on the server is performing a heap operation (like processing a public key or dealing with packet encryption contexts).

If the SIGALRM hits during a free() call in the main loop:

  1. Main thread free() is manipulating heap chunks.
  2. Signal fires.
  3. Handler calls syslog(), which calls malloc()/free().
  4. The heap structures (arenas/bins) are left in an inconsistent state.

Attackers can leverage this inconsistency to write arbitrary data into heap memory, eventually overwriting function pointers or ROP chains to gain execution.

The Reality Check:

  • Difficulty: High. It takes on average ~10,000 attempts (6-8 hours) to win the race against a standard ASLR-enabled system.
  • Noise: It generates massive amounts of logs (syslog spam), making it very loud.
  • Reward: Unauthenticated Root Shell.

The Impact: Why We Panic

Why is an 8-hour brute force attack considered critical?

  1. Ubiquity: OpenSSH is everywhere.
  2. Privilege: This isn't a user-level compromise. sshd runs as root to handle the initial connection. If you pop this, you own the box completely.
  3. Stealth (ironically): While the attack generates logs, many organizations don't monitor syslog volume alerts. An attacker can run this overnight against a targeted high-value server.

Specific targets are glibc-based Linux distributions (Debian, Ubuntu, Red Hat, etc.). Alpine Linux (using musl libc) is generally immune because musl's allocator doesn't have the same behavior regarding syslog safety.

The Mitigation: Stop the Bleeding

You have two choices: Patch or Reconfigure.

Option 1: Patch (Preferred) Upgrade to OpenSSH 9.8p1 or later. The vendors (Canonical, RedHat, Debian) have backported fixes, so apt update && apt upgrade is your friend.

Option 2: The Kill Switch If you cannot patch immediately, you can effectively kill the exploit path by setting the LoginGraceTime to 0 in your sshd_config.

# /etc/ssh/sshd_config
LoginGraceTime 0

[!WARNING] Setting LoginGraceTime 0 exposes you to a different problem: a Denial of Service (DoS). An attacker can open thousands of connections and hold them open indefinitely, exhausting your server's max connection slots. However, a DoS is usually better than a Root RCE.

Fix Analysis (1)

Technical Appendix

CVSS Score
8.1/ 10
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
EPSS Probability
0.10%
Top 100% most exploited
14,000,000
via Shodan

Affected Systems

OpenSSH 8.5p1 through 9.7p1glibc-based Linux systems (Ubuntu, Debian, CentOS, RHEL, Fedora)32-bit systems (easier to exploit)64-bit systems (harder due to ASLR)

Affected Versions Detail

Product
Affected Versions
Fixed Version
OpenSSH
OpenBSD
>= 8.5p1, < 9.8p19.8p1
AttributeDetail
CWE IDCWE-364 (Signal Handler Race Condition)
CVSS v3.18.1 (High)
Attack VectorNetwork
Privileges RequiredNone
User InteractionNone
Exploit StatusProof of Concept Available
CWE-364
Signal Handler Race Condition

The software handles a signal in a way that causes a race condition or other unsafe behavior, often leading to memory corruption or deadlock.

Vulnerability Timeline

Vulnerability introduced in OpenSSH 8.5p1
2020-10-01
Qualys identifies the regression
2024-05-01
Vulnerability Disclosed & Patched
2024-07-01
Added to CISA KEV
2024-07-08

Subscribe to updates

Get the latest CVE analysis reports delivered to your inbox.