How to fix CVE-2024-45337 – Step-by-Step Guide
CVE-2024-45337 addresses a critical vulnerability in Go's crypto/ssh package. This flaw, rated CVSS 9.1, allows unauthorized SSH authentication bypass. It impacts applications using ServerConfig.PublicKeyCallback for server-side SSH authentication.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
This vulnerability stems from a logic flaw within Go's crypto/ssh library. Specifically, applications using ServerConfig.PublicKeyCallback can incorrectly authorize connections. This occurs even if the callback approves a public key but the subsequent authentication process fails, leading to an authentication bypass.
Impact and Risks for your Infrastructure
The critical impact of CVE-2024-45337 is unauthorized SSH authentication bypass. Attackers can gain access to affected Go applications or servers by presenting any public key, circumventing intended security measures. This can lead to full system compromise or data exfiltration.
Step-by-Step Mitigation Guide
To mitigate CVE-2024-45337, update your Go environment to version 1.22.10 or later, or 1.23.4 or later. Verify the update by checking your Go version (`go version`) and recompiling affected applications. This ensures the patched crypto/ssh library is in use, closing the authentication bypass vulnerability.
- 1Upgrade Go to 1.22.10+ or 1.23.4+.
- 2Review your PublicKeyCallback implementation to ensure it rejects unauthorized keys.
- 3Add explicit key allowlist validation inside PublicKeyCallback.
- 4Rotate SSH host keys and audit SSH access logs for anomalies.
- 5Run static analysis (govulncheck) to detect usage of vulnerable patterns.
- 6Pin allowed public keys in your callback rather than relying on post-callback checks.