How to fix CVE-2024-45337 – Step-by-Step Guide
CVE-2024-45337 addresses a critical vulnerability in the Go crypto/ssh standard library. This flaw, named "Misuse of ServerConfig.PublicKeyCallback," allows for unauthorized SSH authentication bypass. It affects Go applications using specific ServerConfig configurations, posing a significant security risk.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
This vulnerability stems from a logic flaw in Go's crypto/ssh when ServerConfig.PublicKeyCallback is used. Even if the callback approves a public key, a subsequent authentication failure should prevent access. However, the flaw incorrectly authorizes connections, bypassing proper authentication checks in affected Go versions < 1.22.10 and < 1.23.4.
Impact and Risks for your Infrastructure
The critical impact of CVE-2024-45337 is unauthorized SSH authentication bypass. Attackers can leverage this flaw to gain unauthorized access to SSH servers running vulnerable Go applications using any public key. This could lead to data breaches, system compromise, and significant operational disruption.
Step-by-Step Mitigation Guide
To mitigate CVE-2024-45337, update your Go environment to version 1.22.10 or 1.23.4, or newer. Verify the fix by recompiling and redeploying affected applications. Ensure your go.mod reflects the updated Go version and conduct thorough authentication tests to confirm the vulnerability is no longer present.
- 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.