x-crypto: authorization bypass via misuse of ServerConfig.PublicKeyCallback (CVE-2024-45337) #shorts

CVE

This CVE addresses an issue within applications using the Golang SSH library, specifically involving the misuse of the ServerConfig.PublicKeyCallback. It was discovered nearly a year ago and is not a zero-day vulnerability. Although no specific attacks have been reported, the flaw allows for authorization bypasses when public keys are not handled correctly. The vulnerability affects versions up to 0.30.x of golang.org/x/crypto/ssh. When misused, the PublicKeyCallback could result in incorrect authorization decisions, where clients can send multiple public keys and cause confusion about which key was used for authentication. This can happen because the SSH protocol lets clients check if a key is valid before proving they control the corresponding private key. The callback function can be invoked with different keys, and some applications might mistakenly authorize a connection based on the wrong key. This is particularly important for developers and users working with the affected library to understand, as it underscores the risks in how authentication mechanisms are implemented.

Watch the full video on YouTube: CVE-2024-45337

Remediation and exploitation details

This chain involves the following actors

This following systems are involved

Attack entry point

Remediation actions

Exploitation actions

Related Content

NOTE: The following related content has not been vetted and may be unsafe.

CVE database technical details

CVE ID
CVE-2024-45337
Description
Applications and libraries which misuse connection.serverAuthenticate (via callback field ServerConfig.PublicKeyCallback) 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/cry...@v0.31.0 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.
Provider
Go
CWE / problem types
CWE-1108: Excessive Reliance on Global Variables
Affected Software Versions
golang.org/x/crypto:golang.org/x/crypto/ssh:[{'version': '0', 'lessThan': '0.31.0', 'status': 'affected', 'versionType': 'semver'}]
Date Published
2024-12-11T18:55:58.506Z
Last Updated
2025-02-18T20:48:40.404Z