CVE-2024-45337: Misuse of ServerConfig.PublicKeyCallback may cause authorization bypass in golang.org/x/crypto
Applications and libraries which misuse the ServerConfig.PublicKeyCallback callback may be susceptible to an authorization bypass. The documentation for ServerConfig.PublicKeyCallback says that "A call to this function does not guarantee that the key offered is in fact used to authenticate." Specifically, the SSH protocol allows clients to inquire about whether a public key is acceptable before proving control of…
Published Dec 11, 2024 · Updated Jan 31, 2025
Affected packages
golang.org/x/crypto
- Ecosystem
- Go
- Affected
- < 0.31.0
- Fixed in
- 0.31.0
- Check
go list -m golang.org/x/crypto
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Applications and libraries which misuse the ServerConfig.PublicKeyCallback callback may be susceptible to an authorization bypass.
The documentation for ServerConfig.PublicKeyCallback says that "A call to this function does not guarantee that the key offered is in fact used to authenticate." Specifically, the SSH protocol allows clients to inquire about whether a public key is acceptable before proving control of the corresponding private key. PublicKeyCallback may be called with multiple keys, and the order in which the keys were provided cannot be used to infer which key the client successfully authenticated with, if any. Some applications, which store the key(s) passed to PublicKeyCallback (or derived information) and make security relevant determinations based on it once the connection is established, may make incorrect assumptions.
For example, an attacker may send public keys A and B, and then authenticate with A. PublicKeyCallback would be called only twice, first with A and then with B. A vulnerable application may then make authorization decisions based on key B for which the attacker does not actually control the private key.
Since this API is widely misused, as a partial mitigation golang.org/x/[email protected] enforces the property that, when successfully authenticating via public key, the last key passed to ServerConfig.PublicKeyCallback will be the key used to authenticate the connection. PublicKeyCallback will now be called multiple times with the same key, if necessary. Note that the client may still not control the last key passed to PublicKeyCallback if the connection is then authenticated with a different method, such as PasswordCallback, KeyboardInteractiveCallback, or NoClientAuth.
Users should be using the Extensions field of the Permissions return value from the various authentication callbacks to record data associated with the authentication attempt instead of referencing external state. Once the connection is established the state corresponding to the successful authentication attempt can be retrieved via the ServerConn.Permissions field. Note that some third-party libraries misuse the Permissions type by sharing it across authentication attempts; users of third-party libraries should refer to the relevant projects for guidance.
Credited to ryanbekhen, SuperSandro2000.
References
- https://github.com/golang/crypto/commit/b4f1988a35dee11ec3e05d6bf3e90b695fbd8909
- https://go.dev/cl/635315
- https://go.dev/issue/70779
- https://groups.google.com/g/golang-announce/c/-nPEi39gI4Q/m/cGVPJCqdAQAJ
- https://pkg.go.dev/vuln/GO-2024-3321
- https://nvd.nist.gov/vuln/detail/CVE-2024-45337
- https://security.netapp.com/advisory/ntap-20250131-0007
- https://github.com/advisories/GHSA-v778-237x-gjrc
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Go vulnerabilities
All Go entriesCVE-2026-39830
golang.org/x/crypto: Invoking client can cause server deadlock on unexpected responses
critical9.1Jun 25, 2026CVE-2026-39831
golang.org/x/crypto: FIDO/U2F security key physical presence check can be bypassed
critical9.1Jun 25, 2026CVE-2026-39832
golang.org/x/crypto doesn't drop invoking agent constraints when forwarding keys
critical9.1Jun 25, 2026CVE-2026-39833
golang.org/x/crypto doesn't enforce invoking key constraints
critical9.1Jun 25, 2026CVE-2026-39834
golang.org/x/crypto vulnerable to infinite loop on large channel writes
critical9.1Jun 25, 2026CVE-2026-42508
golang.org/x/crypto vulnerable to auth bypass via unenforced @revoked status
critical9.1Jun 25, 2026
