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, named 'Misuse of ServerConfig.PublicKeyCallback', allows for unauthorized SSH authentication bypass. It affects Go versions prior to 1.22.10 and 1.23.4.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
The vulnerability stems from a logic flaw in Go's crypto/ssh ServerConfig.PublicKeyCallback. Applications using this callback may incorrectly authorize connections even if the key is approved but subsequent authentication fails. This bypasses intended security checks, allowing unauthorized access.
Impact and Risks for your Infrastructure
This critical flaw enables unauthorized SSH authentication bypass in affected Go applications. Attackers can gain unauthorized access to SSH servers by presenting any public key, circumventing security controls. This can lead to data breaches, system compromise, and significant operational disruption.
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 update by checking your Go version using `go version`. This ensures the patched crypto/ssh library is in use, resolving 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.