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," can lead to unauthorized access in Go applications. It's crucial for developers to understand and address this high-severity issue promptly.
What is Go crypto/ssh – Misuse of ServerConfig.PublicKeyCallback?
This vulnerability stems from a logic flaw within `crypto/ssh`'s `ServerConfig.PublicKeyCallback`. Applications using this callback may incorrectly authorize SSH connections. Even if the actual authentication fails, a misconfigured or improperly implemented callback could approve a public key, bypassing intended security checks and granting unauthorized access.
Impact and Risks for your Infrastructure
The primary impact is an unauthorized SSH authentication bypass in affected Go applications. Attackers can exploit this flaw to authenticate to SSH servers using virtually any public key, gaining unauthorized access to systems. This critical vulnerability (CVSS 9.1) poses a significant risk of data breaches and system compromise.
Step-by-Step Mitigation Guide
To fix CVE-2024-45337, update your Go environment to version 1.22.10 or later, or 1.23.4 or later. Verify the update by checking your Go version (`go version`) to ensure the patched library is in use. This upgrade directly addresses the `PublicKeyCallback` logic flaw, restoring proper SSH authentication security.
- 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.