How to fix CVE-2024-45337 – Step-by-Step Guide
CVE-2024-45337 addresses a critical vulnerability in the Go standard library's crypto/ssh package. This flaw enables unauthorized SSH authentication bypass in applications that improperly use ServerConfig.PublicKeyCallback.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
The Go crypto/ssh library has a logic flaw where applications using ServerConfig.PublicKeyCallback can incorrectly authorize connections. This occurs even if the callback approves a key, but the overall authentication process fails. The vulnerability allows an authentication bypass due to a misstep in the SSH authentication flow.
Impact and Risks for your Infrastructure
This critical vulnerability leads to unauthorized SSH authentication bypass in affected Go applications. Attackers can authenticate to SSH servers using any public key, potentially gaining unauthorized access to systems and sensitive data.
Step-by-Step Mitigation Guide
To mitigate CVE-2024-45337, update your Go applications to Go 1.22.10+ or Go 1.23.4+. Verify the fix by ensuring your Go environment uses the patched versions and redeploying any affected SSH server applications.
- 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.