How to fix CVE-2024-45337 – Step-by-Step Guide
CVE-2024-45337 addresses a critical authentication bypass in Go's `crypto/ssh` library. Named 'Misuse of ServerConfig.PublicKeyCallback', this flaw allows unauthorized access to SSH servers built with affected Go versions, posing a severe security risk.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
The vulnerability stems from a logic flaw in `crypto/ssh`'s `ServerConfig.PublicKeyCallback`. If an application's callback approves a key but authentication fails, the connection may still be incorrectly authorized. This bypasses intended authentication, affecting Go versions prior to 1.22.10 and 1.23.4.
Impact and Risks for your Infrastructure
This critical flaw enables unauthorized SSH authentication bypass, allowing attackers to access Go applications using any public key. This can lead to severe data breaches, system compromise, and unauthorized control over affected infrastructure, posing significant security risks.
Step-by-Step Mitigation Guide
To mitigate CVE-2024-45337, upgrade your Go applications to Go 1.22.10+ or 1.23.4+. Verify the fix by ensuring your Go environment is updated and re-deploying affected services. Regularly audit `PublicKeyCallback` implementations for correct authentication logic to prevent similar issues.
- 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.