CVE-2024-45337: Golang.org/x/crypto Misuse Of ServerConfig.PublicKeyCallback May Cause Vulnerability

CRITICAL
Advisory Identifier: GHSA-v778-237x-gjrc
CVSS 9.1
CWE-285
Published
Advisory Summary

CVE-2024-45337 is a CRITICAL (CVSS 9.1) misuse of serverconfig.publickeycallback may cause vulnerability (CWE-285: Improper Authorization) affecting Golang.org/x/crypto libraries in the Go ecosystem. The issue involves misuse of serverconfig.publickeycallback may cause authorization bypass in golang.org/x/crypto. Remediation is available by upgrading affected packages to version 0.31.0.

CVE-2024-45337 at a Glance

CVE Identifier CVE-2024-45337
GHSA Identifier GHSA-v778-237x-gjrc
Severity CRITICAL
CVSS v3.1 Base Score 9.1
CWE Classification CWE-285: Improper Authorization
Affected Product Golang.org/x/crypto
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 9.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2024-45337

To remediate this vulnerability, upgrade all affected Golang.org/x/crypto dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

golang.org/x/crypto fixed: 0.31.0
Upgrade golang.org/x/crypto to 0.31.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for golang.org/x/crypto

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-45337, inspect your project dependencies for Golang.org/x/crypto:

inspect dependencies for golang.org/x/crypto

Analyze the terminal output to locate any version of Golang.org/x/crypto in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.31.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-285: Improper Authorization, where the product does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action. In Golang.org/x/crypto, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

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/crypto@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.

CVE-2024-45337 Affected Golang.org/x/crypto Versions

1 component(s)
Fixed Versions:
0.31.0
Product / Package Ecosystem Affected Versions Fixed Version
golang.org/x/crypto
Go
< 0.31.0
0.31.0

References

Frequently Asked Questions

What is CVE-2024-45337?
CVE-2024-45337 is a security vulnerability in Golang.org/x/crypto involving Misuse of ServerConfig.PublicKeyCallback may cause authorization bypass in golang.org/x/crypto under CWE-285: Improper Authorization.
Which Golang.org/x/crypto versions are affected?
Affected versions include releases prior to 0.31.0 across affected packages: golang.org/x/crypto.
What version fixes CVE-2024-45337?
Upgrading to 0.31.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is golang.org/x/crypto affected?
Yes, golang.org/x/crypto is affected in releases prior to 0.31.0. Upgrade your dependency to 0.31.0 or later.
What is the CVSS score of CVE-2024-45337?
CVE-2024-45337 has a CVSS v3.1 base score of 9.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2024-45337?
CVE-2024-45337 is classified under CWE-285: Improper Authorization (The product does not perform or incorrectly performs an authorization check when an actor attempts to access a resource or perform an action.).
How can I check Go dependencies for CVE-2024-45337?
Run the dependency tree command: 'inspect dependencies for golang.org/x/crypto'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-v778-237x-gjrc",
  "modified" : "2025-01-31T15:30:43Z",
  "published" : "2024-12-11T22:03:04Z",
  "aliases" : [ "CVE-2024-45337" ],
  "summary" : "Misuse of ServerConfig.PublicKeyCallback may cause authorization bypass in golang.org/x/crypto",
  "details" : "Applications and libraries which misuse the ServerConfig.PublicKeyCallback callback may be susceptible to an authorization bypass.\n\nThe 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.\n\nFor 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.\n\nSince this API is widely misused, as a partial mitigation golang.org/x/crypto@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.\n\nUsers 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "golang.org/x/crypto"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.31.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-45337"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/golang/crypto/commit/b4f1988a35dee11ec3e05d6bf3e90b695fbd8909"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/golang/crypto"
  }, {
    "type" : "WEB",
    "url" : "https://go.dev/cl/635315"
  }, {
    "type" : "WEB",
    "url" : "https://go.dev/issue/70779"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/g/golang-announce/c/-nPEi39gI4Q/m/cGVPJCqdAQAJ"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2024-3321"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20250131-0007"
  }, {
    "type" : "WEB",
    "url" : "http://www.openwall.com/lists/oss-security/2024/12/11/2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-285" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-12-11T22:03:04Z",
    "nvd_published_at" : "2024-12-12T02:02:07Z"
  }
}