How to fix CVE-2024-45337 – Step-by-Step Guide
CVE-2024-45337, named 'Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback', is a critical vulnerability (CVSS 9.1) affecting the Go standard library. It addresses a flaw in SSH server authentication logic.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
This vulnerability arises from a logic flaw in Go's crypto/ssh package. Applications using ServerConfig.PublicKeyCallback may incorrectly authorize connections. Even if the callback approves a key, subsequent authentication failures can still grant unauthorized access due to an authentication flow error.
Impact and Risks for your Infrastructure
The primary impact is an unauthorized SSH authentication bypass in Go applications. Attackers can exploit this flaw to authenticate to affected SSH servers using any public key, circumventing intended security measures and gaining unauthorized access to systems.
Step-by-Step Mitigation Guide
To mitigate CVE-2024-45337, upgrade your Go environment to version 1.22.10+ or 1.23.4+. Verify the fix by recompiling and deploying your Go applications with the patched Go toolchain. Ensure all affected services are running the updated binaries.
- 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.