Get a Demo
Under Attack?
A tropical beach setting with palm trees features a red sign with an exclamation mark. The sign reads OpenSSH CVE-2024-6387 while ocean waves crash in the background.

regreSSHion: RCE in OpenSSH’s Server on glibc-based Linux Systems (CVE-2024-6387)

<br />
<b>Warning</b>:  Undefined variable $photo in <b>/nas/content/live/landing173/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code</b> on line <b>24</b><br />
<br />
<b>Warning</b>:  Trying to access array offset on value of type null in <b>/nas/content/live/landing173/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code</b> on line <b>24</b><br />
<br />
<b>Warning</b>:  Undefined variable $photo in <b>/nas/content/live/landing173/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code</b> on line <b>24</b><br />
<br />
<b>Warning</b>:  Trying to access array offset on value of type null in <b>/nas/content/live/landing173/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code</b> on line <b>24</b><br />
Eliad Mualem, Moshe Hassan July 01, 2024

OpenSSH is widely known for managing secure shell connections (SSH). However, a recently discovered vulnerability in OpenSSH’s server (sshd), known as regreSSHion, has been identified. If a client does not authenticate within the LoginGraceTime (120 seconds by default, 600 seconds in older versions), sshd’s SIGALRM handler is called asynchronously. This signal handler calls functions that are not safe to use in such contexts (like syslog()). This issue affects sshd in its default configuration.

This vulnerability is a regression of CVE-2006-5051, reported by Mark Dowd in 2006, and reintroduced in October 2020 with OpenSSH 8.5p1.

Affected OpenSSH Versions

  • OpenSSH versions earlier than 4.4p1: Vulnerable unless patched for CVE-2006-5051 and CVE-2008-4109.
  • Versions from 4.4p1 up to, but not including, 8.5p1: Not vulnerable due to a patch for CVE-2006-5051.
  • Versions from 8.5p1 up to, but not including, 9.8p1: Vulnerable again due to the accidental removal of a critical safety component.

This vulnerability is exploitable remotely on glibc-based Linux systems. The syslog() function in these environments calls functions like malloc() and free(), which are not safe to use in a signal handler. This can lead to remote code execution as root since sshd runs with full privileges. OpenBSD is not affected by this vulnerability because it uses a safer version of syslog() that does not have this issue.

To exploit this vulnerability remotely, techniques from Michal Zalewski’s paper “Delivering Signals for Fun and Profit” (2001) were utilized.

Exploitation Scenarios

Various OpenSSH versions on i386 were targeted to understand the vulnerability better:

  1. SSH-2.0-OpenSSH_3.4p1 Debian 1:3.4p1-1.woody.3 (Debian 3.0r6, 2005)
    • Approach: Interrupting a call to free() with SIGALRM during public-key parsing.
    • Outcome: This leads to remote root access after approximately 10,000 attempts, which is about one week with default settings.
  2. SSH-2.0-OpenSSH_4.2p1 Debian-7ubuntu3 (Ubuntu 6.06.1, 2006)
    • Approach: Interrupting pam_start() with SIGALRM.
    • Outcome: A similar issue results in remote root access after about 10,000 attempts, roughly one to two days with default settings.
  3. SSH-2.0-OpenSSH_9.2p1 Debian-2+deb12u2 (Debian 12.5.0, 2024)
    • Approach: Interrupting malloc() with SIGALRM during public-key parsing.
    • Outcome: Remote root access is achieved after about 10,000 attempts, which takes approximately three to four hours with 100 connections per 120 seconds.

Research is ongoing, and efforts are being made to develop a more robust exploit for modern systems with stronger security features.

Patches and Mitigation

On June 6, 2024, this issue was fixed by commit 81c1099. The commit moved the unsafe code out of the SIGALRM handler to a safer context, effectively addressing the vulnerability:

Mitigation

If backporting this commit is difficult, the issue can be mitigated by removing the unsafe code from sshsigdie(). This approach reduces the risk of exploitation by ensuring that potentially vulnerable code is not executed in an unsafe context.

for example:

sshsigdie(const char *file, const char *func, int line, int showfunc,
    LogLevel level, const char *suffix, const char *fmt, ...)
{
#if 0
        va_list args;

        va_start(args, fmt);
        sshlogv(file, func, line, showfunc, SYSLOG_LEVEL_FATAL,
            suffix, fmt, args);
        va_end(args);
#endif
        _exit(1);
}

If updating or recompiling sshd is not feasible, setting LoginGraceTime to 0 in the configuration file will prevent the race condition but may lead to denial of service (exhaustion of MaxStartups connections).

How Upwind Protects You from regreSSHion CVE-2024-6387

Screenshot-2024-07-01-at-6.42.34%E2%80%AFAM-1024x606

The Upwind Cloud Security Platform offers several solutions to OpenSSH vulnerabilities and other critical vulnerabilities by providing the following:

image_2024-07-01_22-39-24-1-1024x534
  • Find Vulnerable Packages with Upwind’s SBOM Explorer: Search for and easily display all packages impacted by CVE-2024-6387, including OpenSSH versions earlier than 4.4p1 and versions from 8.5p1 up to, but not including, 9.8p1.
  • View Scope of Resources: Find all resources that contain CVE-2024-6387, which cloud accounts they are in, and which clusters, pods, namespaces, VMs and resources they are using. View the impact CVE-2024-6387 has on resources in your environment including package dependencies available fixes.
  • Understand Risk Context: View the criticality of risk that CVE-2024-6387 poses in your environment, including toxic combinations of resources impacted by the CVE that also have internet exposure, are talking to a database, contain secrets, contain sensitive data and more.
  • Prioritize Package Upgrades: Create a list of vulnerable resources that should be prioritized for updates, using the recommended fixes listed in this article to quickly secure your environment.

Get Further Help from Upwind MDR

Upwind’s expert security team also provides 24/7 managed detection and response services, giving you real-time support for CVE-2024-6387 and all zero days or critical vulnerability findings. For additional help finding vulnerable packages, identifying the scope of resource usage with the CVE, understanding their risk context and prioritizing package upgrades contact the Upwind MDR team at [email protected] or schedule a demo.

Contents

Further Reading

AI-DR-Hero (1)

Upwind AI DR is Generally Available: metaCatch Compromised AI Agents in Real Time

We're excited to announce that Upwind AI DR (AI Detection & Response) is now generally available. AI DR gives security teams real-time detection and response for the AI agents running in production, not by bolting on a new sensor, but by extending the runtime intelligence Upwind already has. The Upwind Cloud & AI Security Platform…
Focus-Mode

Focus Mode for AI Security: A Dedicated Workspace for Identifying and Securing Your AI Stack 

When we launched Focus Mode, we built it around the way security teams actually work: Vulnerability Management, Cloud Security Posture, Attack Surface Management, Threat Detection & Response, Administration. Each one strips away everything unrelated to the job at hand. AI Security is the next domain in the Focus Mode lineup, and it's built for a…
The Risk Isn't What You Prompt, It's What You Built.

The Risk Isn’t What You Prompt, It’s What You Built

Key Takeaways: Agentic AI security is an architecture problem, not a policy problem. Most organizations have adopted AI agents in the form of coding assistants, autonomous workflow tools, internal chatbots connected to production systems, but without establishing the foundational security frameworks those systems require. The adoption pressure is real. Telling your engineering team to stop…
Add the Upwind RSS Feed to Slack
Connect the Upwind RSS Feed to your Slack.
Follow the how-to here.
Threat RSS
Add the Upwind RSS Feed to Slack
Connect the Upwind RSS Feed to your Slack.
Follow the how-to here.
Main RSS