A vulnerability in OpenSSH that allows remote code execution with root privileges on servers running Glibc.
Qualys has identified a critical vulnerability (CVE-2024-6387) in OpenSSH that allows remote code execution with root privileges without passing authentication. The vulnerability, which was codenamed regreSSHion, has been present since OpenSSH version 8.5 on systems with the Glibc standard library.
The possibility of performing an attack was demonstrated on a 32-bit system with Glibc with ASLR (address space randomization) protection enabled. For a successful attack in the laboratory, it took 6-8 hours, during which connections were continuously established with the server at the maximum allowed intensity in the sshd configuration. Performing the attack is simplified and requires less time on systems without ASLR or on distributions that use modified OpenSSH, which disables re-randomization of ASLR for each connection.
The possibility of an attack on 64-bit systems is also possible, but a working exploit for such systems is not yet ready. It is assumed that an attack on 64-bit systems will take much longer, but no more than a week. OpenSSH in OpenBSD is not affected by the problem, but in other systems based on standard libraries other than Glibc, it is theoretically possible to adapt the method to perform an attack (this issue has not yet been studied in Qualys).
The vulnerability is fixed in the OpenSSH 9.8 release (patch) published today. As a workaround for blocking the vulnerability in sshd_config, you can set the parameter "LoginGraceTime=0".
The vulnerability occurred as a result of a regressive change that was included in the OpenSSH 8.5 release and leads to a race condition in the signal processing code in sshd. The regression led to the termination of protection against the old vulnerability CVE-2006-5051, which was manifested before the OpenSSH 4.4 version (2006) and was of a theoretical nature. During the development of OpenSSH 8.5, the "#ifdef DO_LOG_SAFE_IN_SIGHAND " block was removed by mistake from the sigdie () function, which is directly called from the SIGALRM handler.
The SIGALRM handler is called asynchronously in sshd if the client has not authenticated within the time limit of the connection timeout (LoginGraceTime, default 120 seconds). The attack is based on the fact that the signal handler calls functions that are not safe for asynchronous signal processing, such as syslog().
-----
The release of OpenSSH 9.8, an open client and server implementation for SSH 2.0 and SFTP protocols, has been published. In addition to fixing a separately announced critical vulnerability (CVE-2024-6387), which allows remote code execution with root rights at the pre-authentication stage, the new version fixes another less dangerous vulnerability and offers several significant changes aimed at improving security.
The second vulnerability allows you to bypass the protection added in version OpenSSH 9.5 against attacks on third-party channels that analyze delays between keystrokes on the keyboard to recreate input. The vulnerability allows you to distinguish packets that create background activity through the simulation of fake keystrokes from packets sent when real keys are pressed, which reduces the effectiveness of the mechanism for hiding interactive input features in ssh traffic. Data on keystrokes allows you to use attacks that recreate input based on the analysis of delays between keystrokes when typing, which depend on the location of keys on the keyboard (for example, the reaction when entering the letter " F "is faster than when entering" Q "or" X", since pressing requires less finger movements).
In addition, it turned out that the implemented algorithm for sending packets with real and fictitious clicks reduced the reliability of another method of protecting against attacks via third-party channels. Starting with the release of OpenSSH 2.9.9, the server sent dummy push packets for console input in echo-off mode, which is used, for example, when entering passwords in su or sudo. The new logic for sending dummy packets allowed passive traffic analysis to select packets with real clicks in echo-off mode for their separate analysis. At the same time, the accuracy of information about the time of clicks is limited, since after dialing, packets are sent not immediately, but at fixed intervals (by default, 20 ms).
Other changes in OpenSSH 9.8:
* At the build stage, support for digital signatures based on the DSA algorithm is disabled by default. In early 2025, the DSA implementation will be removed from the codebase. The reason for deletion is the level of protection in the DSA that does not meet modern requirements. The cost of continuing to maintain the insecure DSA algorithm is not justified, and its removal will encourage the termination of DSA support in other SSH implementations and cryptographic libraries.
• For additional protection against exploiting vulnerabilities that require a large number of connections to the sshd, a new security mode has been implemented and enabled by default, which also helps to block automated password matching attacks, during which bots try to guess the user's password by going through various typical combinations. Protection is implemented by blocking IP addresses that record a large number of failed connection attempts . sshd monitors the termination status of child processes, identifying situations when authentication failed or when the process was aborted due to a failure, and when a certain threshold is exceeded, it starts blocking requests from problematic IP addresses or subnets. The persourcepenalities, PerSourceNetBlockSize, and PerSourcePenaltyExemptList parameters are used to configure the lock threshold, subnet mask, and exception list.
* Split sshd into several separate executable files. The sshd-session process is allocated from sshd, which performs tasks related to session processing. The sshd process retains the functions responsible for accepting network connections, checking configuration, loading host keys, and managing running processes in accordance with the MaxStartups parameter. Thus, the sshd executable file now contains the minimum functionality required to accept a new network connection and run sshd-session to process the session.
• The text of some error messages recorded in the log has changed. In particular, a number of messages are now sent on behalf of the "sshd-session" process, rather than "sshd".
* The ssh-keyscan utility now outputs information about the protocol version and hostname to the standard stream, instead of STDERR. To disable the output, the "-q " option is suggested.
* SSH implements the ability to disable the rollback from using the host key certificate to using plain host keys via the HostKeyAlgorithms directive.
* In the portable version of sshd, the argv[0] value is no longer used to determine the name of the PAM service. To set the name of the PAM service, a new directive "PAMServiceName" has been added to sshd_config, which is set to "sshd"by default.
* In the portable version of sshd, automatically generated files are saved (configure script, config.h.in etc.) in the Git branch with releases (for example, V_9_8), which made it possible to synchronize the composition of digitally signed tar archives and branches in Git.
* In the portable version of ssh and ssh-agent, the SSH_ASKPASS mode is set when the WAYLAND_DISPLAY environment variable is present, similar to how it was done for X11 when the DISPLAY environment variable is present.
* The portable version of sshd adds support for sending notifications to systemd when a listening network socket is created or restarted, using separate code that does not access the libsystemd library.