How to fix CVE-2024-6387 – Step-by-Step Guide
CVE-2024-6387, dubbed 'regreSSHion', is a critical vulnerability affecting OpenSSH versions 8.5p1 through 9.7p1. This flaw enables unauthenticated remote code execution (RCE) as root on glibc-based Linux systems. Immediate patching is essential to prevent severe system compromise.
What is OpenSSH regreSSHion – Unauthenticated RCE?
CVE-2024-6387 stems from a signal handler race condition within the OpenSSH server (sshd). This race allows an unauthenticated attacker to trigger a memory corruption, leading to arbitrary code execution. Specifically, it affects OpenSSH 8.5p1-9.7p1 on glibc Linux systems, bypassing authentication entirely.
Impact and Risks for your Infrastructure
The impact of CVE-2024-6387 is severe: full root compromise of affected SSH servers. Attackers can execute arbitrary code without authentication, gaining complete control over the system. This leads to data exfiltration, service disruption, and potential lateral movement across your infrastructure.
Step-by-Step Mitigation Guide
To mitigate CVE-2024-6387, immediately upgrade OpenSSH to version 9.8p1 or later. Verify the fix by checking your OpenSSH version (`ssh -V`) to ensure it's 9.8p1+. Restart the sshd service after the upgrade to apply changes. Consider disabling SSH access from untrusted networks as an interim measure.
- 1Upgrade OpenSSH to 9.8p1 or later immediately.
- 2Restrict SSH access via firewall: allow only trusted IPs on port 22.
- 3Enable fail2ban or equivalent rate-limiting to slow exploitation attempts.
- 4Set LoginGraceTime 0 in sshd_config as a temporary workaround (disables grace period).
- 5Audit SSH server logs for exploitation attempts (look for connection floods).
- 6Consider moving SSH to a non-standard port or VPN-only access (Tailscale, WireGuard).