How to fix CVE-2024-45337 – Step-by-Step Guide
CVE-2024-45337 addresses a critical authentication bypass vulnerability in Go's `crypto/ssh` library. This flaw could allow unauthorized access to SSH servers built with affected Go versions. Immediate action is required to secure your applications.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
This critical vulnerability, CVE-2024-45337, stems from a logic flaw in Go's `crypto/ssh` `ServerConfig.PublicKeyCallback`. Applications might incorrectly authorize SSH connections even if the `PublicKeyCallback` approves a key but subsequent authentication fails. This bypasses intended security checks, allowing unauthorized access.
Impact and Risks for your Infrastructure
The impact of CVE-2024-45337 is severe: unauthorized SSH authentication bypass. Attackers can gain access to Go applications acting as SSH servers using any public key, potentially leading to full system compromise, data exfiltration, or service disruption. This poses a critical risk to infrastructure.
Step-by-Step Mitigation Guide
To mitigate CVE-2024-45337, update your Go applications to versions 1.22.10+ or 1.23.4+. Recompile and redeploy your SSH server applications. Verify the fix by ensuring your `go.mod` reflects the updated Go version and conducting thorough authentication tests.
- 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.