Miggo Logo

CVE-2024-45337: Misuse of ServerConfig.PublicKeyCallback may cause authorization bypass in golang.org/x/crypto

9.1

CVSS Score
3.1

Basic Information

EPSS Score
0.96913%
Published
12/11/2024
Updated
1/31/2025
KEV Status
No
Technology
TechnologyGo

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Package NameEcosystemVulnerable VersionsFirst Patched Version
golang.org/x/cryptogo< 0.31.00.31.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability CVE-2024-45337 concerns a potential authorization bypass in applications misusing ServerConfig.PublicKeyCallback in golang.org/x/crypto/ssh. The core issue is that the callback might be invoked with multiple keys, and applications might incorrectly assume the last key seen by the callback is the one used for authentication. The provided patch (commit b4f1988a35dee11ec3e05d6bf3e90b695fbd8909) addresses this by modifying the public key caching mechanism within the SSH server implementation.

The primary change in the patch is to the ssh/server.go file, specifically:

  1. The constant maxCachedPubKeys is reduced from 16 to 1.
  2. The (*pubKeyCache).add method is modified to implement a strict FIFO (First-In, First-Out) behavior for this cache of size 1.

The function (*pubKeyCache).add is directly involved in managing the state that could lead to the vulnerability. Its previous behavior (allowing a larger cache that wasn't necessarily ordered by authentication success) contributed to the possibility of the user's PublicKeyCallback being misled about which key was ultimately used for authentication. By changing (*pubKeyCache).add to maintain only the single most recent key, the library now enforces that the last call to PublicKeyCallback (in a successful public key authentication scenario) corresponds to the authenticated key. Therefore, (*pubKeyCache).add is identified as a key function related to the vulnerability because its previous implementation was part of the mechanism that allowed the confusing state, and its modification is central to the mitigation.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

*ppli**tions *n* li*r*ri*s w*i** misus* t** S*rv*r*on*i*.Pu*li*K*y**ll***k **ll***k m*y ** sus**pti*l* to *n *ut*oriz*tion *yp*ss. T** *o*um*nt*tion *or S*rv*r*on*i*.Pu*li*K*y**ll***k s*ys t**t "* **ll to t*is *un*tion *o*s not *u*r*nt** t**t t** k*

Reasoning

T** vuln*r**ility *V*-****-***** *on**rns * pot*nti*l *ut*oriz*tion *yp*ss in *ppli**tions misusin* `S*rv*r*on*i*.Pu*li*K*y**ll***k` in `*ol*n*.or*/x/*rypto/ss*`. T** *or* issu* is t**t t** **ll***k mi**t ** invok** wit* multipl* k*ys, *n* *ppli**tio