A severe Remote Unauthenticated Code Execution (RCE) vulnerability has been recently identified in OpenSSH’s server (sshd) on glibc-based Linux systems. This high-severe flaw, assigned CVE-2024-6387, poses a significant security risk as it allows unauthenticated remote code execution as root.
This discovery follows another significant vulnerability identified in the XZ Utils library just a few months ago, highlighting the ongoing challenges in cybersecurity. Although CVE-2024-6387 is a serious flaw, it is quite difficult to exploit in practice. Nonetheless, it is crucial to understand the risk and take steps to protect your systems. SSH is widely used across various platforms on Linux servers, making its security vitally important.
This issue arises when a client fails to authenticate within the LoginGraceTime period, which is set to 120 seconds by default in recent versions and 600 seconds in older versions. When this timeout is reached, sshd’s SIGALRM handler is triggered. The problem occurs because this handler calls various functions, such as syslog(), which are unsafe to call from within a signal handler. This race condition poses a significant risk to systems running the default sshd configuration.
Interestingly, this vulnerability is not entirely new. It is a regression of a previously identified issue, CVE-2006-5051, reported by Mark Dowd in 2006. That earlier vulnerability also involved a signal handler race condition in OpenSSH versions prior to 4.4, which could lead to a denial of service or potentially allow remote code execution.
The regression occurred in October 2020 with the release of OpenSSH 8.5p1. During an update to the logging infrastructure, a crucial directive (#ifdef DO_LOG_SAFE_IN_SIGHAND) was inadvertently removed from the sigdie() function. This function, directly called by sshd’s SIGALRM handler, was made unsafe again. Here is a breakdown of the vulnerability’s timeline:
The implications of this vulnerability are particularly severe on glibc-based Linux systems, where syslog() itself may invoke other unsafe functions like malloc() and free(). This creates a scenario where an attacker can potentially execute arbitrary code as root without needing to authenticate. This is because sshd’s privileged code operates with full system privileges and lacks sandboxing.
This vulnerability is caused by a signal handler race condition in OpenSSH’s server (sshd), which impacts systems in their default configuration. Searches using Censys and Shodan revealed over 14 million potentially vulnerable OpenSSH server instances exposed to the Internet. Anonymized data from Qualys indicates that approximately 700,000 external internet-facing instances are vulnerable, accounting for 31% of all internet-facing instances with OpenSSH in the global customer base. Notably, over 0.14% of these vulnerable instances are running End-Of-Life/End-Of-Support versions of OpenSSH.
By understanding the detailed exploitation process, system administrators and security professionals can better appreciate the severity of this vulnerability and the importance of implementing timely patches and robust security measures.
Exploiting the signal handler race condition vulnerability in OpenSSH requires a deep understanding of timing attacks and memory manipulation. Below, we outline the steps an attacker would take to exploit this vulnerability.
The attacker initiates numerous connections to the target OpenSSH server, repeatedly triggering the LoginGraceTime limit without completing authentication. This action causes the server to raise the SIGALRM signal.
Exploitation hinges on interrupting the server’s signal handler at the exact moment it executes non-async-signal-safe operations, such as syslog(). The attacker sends specially crafted inputs to manipulate the server’s memory layout, leading to heap corruption.
By manipulating the server’s memory, the attacker creates an inconsistent state in the heap. This is achieved by triggering the SIGALRM signal during memory allocation or deallocation functions like malloc() or free(). Exploiting this vulnerability typically requires around 10,000 attempts. Each attempt resets the LoginGraceTime timer, providing the attacker a new window to trigger the vulnerability.
During the exploitation process, the attacker adjusts the timing of their inputs based on feedback from previous attempts. This fine-tuning is crucial for successfully interrupting the signal handler at the critical moment. Despite modern defenses like Address Space Layout Randomization (ASLR) and No-eXecute (NX), the attacker uses predictable memory patterns and advanced timing techniques to bypass these protections.
Successful exploitation allows the attacker to overwrite critical memory structures, leading to the execution of arbitrary code and remote control of the server with root privileges.
Researchers have primarily focused on virtual machines with mostly stable network conditions. While significant progress has been made, further improvements are anticipated, particularly for exploiting newer amd64 systems where ASLR is stronger. A related bug report discovery led to immediate communication with OpenSSH developers, underscoring the importance of swift action in addressing such vulnerabilities.
OpenSSH (Open Secure Shell) is an essential suite of secure networking utilities based on the Secure Shell (SSH) protocol. It ensures robust encryption for privacy and secure file transfers, making it vital for remote server management and secure data communication. Despite the recent vulnerability, OpenSSH remains a benchmark in software security due to its extensive security and authentication features, scalability, and ability to enforce robust access controls.
OpenBSD systems are unaffected by this bug, thanks to a secure mechanism developed in 2001 that prevents this vulnerability.
If exploited, this vulnerability could lead to full system compromise, allowing attackers to execute arbitrary code with the highest privileges. This could result in a complete system takeover, installation of malware, data manipulation, and creation of backdoors for persistent access. It could also facilitate network propagation, enabling attackers to traverse and exploit other vulnerable systems within the organization. The remote race condition nature of this vulnerability makes it challenging to exploit, but advancements in deep learning could increase the success rate.
All versions of the RELIANOID Load Balancer already have the updated packages in the repository, reflecting our commitment to providing the most secure and reliable load balancer. Ensure to have the latest updates applied in your load balancers and servers.
Stay vigilant and ensure your systems are patched and protected against this significant security threat. Contact with our security experts to know more about this vulnerability.