How to fix CVE-2024-45337 – Step-by-Step Guide
CVE-2024-45337 is a critical vulnerability in the Go standard library's crypto/ssh package. Named 'Misuse of ServerConfig.PublicKeyCallback,' this flaw can lead to unauthorized SSH authentication bypass in Go applications.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
The vulnerability arises from a logic flaw in crypto/ssh's ServerConfig.PublicKeyCallback. Applications may incorrectly authorize connections when the callback approves a key, but the subsequent authentication process fails. This allows an attacker to bypass the intended authentication flow.
Impact and Risks for your Infrastructure
This critical flaw enables unauthorized SSH authentication bypass, allowing attackers to gain access to Go-based SSH servers. Attackers can authenticate using any public key, potentially compromising sensitive systems and data.
Step-by-Step Mitigation Guide
To fix CVE-2024-45337, update your Go applications to Go 1.22.10+ or Go 1.23.4+. Verify the fix by checking your Go version and ensuring your SSH server implementations correctly handle the PublicKeyCallback logic.
- 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.