
Mitigation Guide for CVE-2024-6387 in OpenSSH
This document outlines the steps for mitigating CVE-2024-6387, a security vulnerability affecting OpenSSH versions from 8.5p1 to 9.8p1. The vulnerability can be mitigated in two ways:
LoginGraceTime setting in the SSH configuration to reduce the window of opportunity for an attack.LoginGraceTimeThe LoginGraceTime parameter specifies the time limit for SSH clients to authenticate successfully. Setting this parameter to 0 can effectively reduce the vulnerability window by requiring immediate authentication upon connection.
LoginGraceTimeOpen the SSH Configuration File
As the root user, open the /etc/ssh/sshd_config file using a text editor. For example:
vim /etc/ssh/sshd_config
Modify the LoginGraceTime Parameter
Locate the LoginGraceTime parameter. If it exists, modify it to:
LoginGraceTime 0
If the parameter does not exist, add it to the file with the same setting.
Save and Close the File After making the changes, save the file and exit the text editor.
Restart the SSH Service Apply the changes by restarting the SSH daemon:
systemctl restart sshd.service
Verify the Configuration (Optional) Ensure that the configuration has been applied correctly:
sshd -T | grep logingracetime
This command should output logingracetime 0, confirming that the setting is applied.
If an upgrade path is available that patches CVE-2024-6387, it is recommended to update OpenSSH to this version. Follow these general steps to upgrade OpenSSH:
Check Current Version Verify the current version of OpenSSH installed on your system:
ssh -V
Search for Available Versions Check if a patched version is available in your distribution's repository:
apt list -a openssh-server
Upgrade OpenSSH If a secure version is available, upgrade using the package manager:
sudo apt update
sudo apt upgrade openssh-server
Restart the SSH Service Restart the SSH daemon to apply the upgrade:
systemctl restart sshd.service
Verify the Upgrade Check the version again to ensure the upgrade was successful:
ssh -V