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, rated CVSS 9.1, impacts applications using ServerConfig.PublicKeyCallback. It allows for unauthorized SSH authentication bypass.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
The vulnerability stems from a logic flaw in crypto/ssh's authentication flow. Applications using ServerConfig.PublicKeyCallback may incorrectly authorize connections. Even if the callback approves a public key, authentication can fail, yet the connection might still be permitted due to this bug. This bypasses intended security checks.
Impact and Risks for your Infrastructure
This critical vulnerability enables unauthorized SSH authentication bypass in affected Go applications. Attackers can exploit this to authenticate to SSH servers using any public key, even if not properly authorized. This could lead to unauthorized access to sensitive systems and data.
Step-by-Step Mitigation Guide
To fix CVE-2024-45337, update your Go environment to version 1.22.10+ or 1.23.4+. Verify the update by checking your Go version. Ensure all applications using crypto/ssh are recompiled with the patched Go version to apply the fix effectively.
- 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.