Miggo Logo

CVE-2023-48223: JWT Algorithm Confusion

5.9

CVSS Score
3.1

Basic Information

EPSS Score
0.3994%
Published
11/20/2023
Updated
11/20/2023
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N
Package NameEcosystemVulnerable VersionsFirst Patched Version
fast-jwtnpm< 3.3.23.3.2

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability stemmed from improper PEM header validation in crypto.js. The root cause was the 'publicKeyPemMatcher' being a static string ('BEGIN PUBLIC KEY') rather than a regex. This affected two key functions: 1) performDetectPublicKeyAlgorithms failed to properly identify RSA-formatted public keys, allowing them to be treated as HS256 secrets. 2) performDetectPrivateKeyAlgorithm incorrectly checked for public key headers in private key validation. Both functions used 'includes()' with the flawed matcher, as shown in the pre-patch code where 'includes(publicKeyPemMatcher)' was replaced with regex 'match()' in the fix commit.

Vulnerable functions

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

WAF Protection Rules

WAF Rule

### Summ*ry T** **st-jwt li*r*ry *o*s not prop*rly pr*v*nt JWT *l*orit*m *on*usion *or *ll pu*li* k*y typ*s. ### **t*ils T** 'pu*li*K*yP*mM*t***r' in '**st-jwt/sr*/*rypto.js' *o*s not prop*rly m*t** *ll *ommon P*M *orm*ts *or pu*li* k*ys. To *xploit

Reasoning

T** vuln*r**ility st*mm** *rom improp*r P*M *****r v*li**tion in *rypto.js. T** root **us* w*s t** 'pu*li*K*yP*mM*t***r' **in* * st*ti* strin* ('***IN PU*LI* K*Y') r*t**r t**n * r***x. T*is *****t** two k*y *un*tions: *) p*r*orm**t**tPu*li*K*y*l*orit