How to fix CVE-2024-45337 – Step-by-Step Guide
CVE-2024-45337 is a critical vulnerability in the Go crypto/ssh package, published December 11, 2024. It allows unauthorized SSH authentication bypass in applications that misuse ServerConfig.PublicKeyCallback. This flaw has a CVSS score of 9.1.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
This vulnerability stems from a logic flaw in Go's crypto/ssh package. When ServerConfig.PublicKeyCallback approves a public key, the authentication flow may proceed even if subsequent authentication fails. This allows an attacker to bypass SSH authentication using any public key if the callback is not correctly implemented.
Impact and Risks for your Infrastructure
The primary impact is unauthorized SSH authentication bypass, allowing attackers to gain illicit access to affected Go applications. This can lead to severe consequences, including data exfiltration, system compromise, and disruption of critical services. Infrastructure relying on vulnerable Go SSH servers is at high risk.
Step-by-Step Mitigation Guide
To mitigate CVE-2024-45337, upgrade your Go runtime to version 1.22.10 or 1.23.4, or newer. Recompile any applications using crypto/ssh with the patched Go version. Verify the fix by ensuring SSH authentication works as expected and unauthorized access attempts are correctly rejected.
- 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.