CVE-2023-48223 fast-jwt JWT Algorithm Confusion

Medium 5.9 Published Updated

Attackers can bypass JWT signature verification by exploiting algorithm confusion in fast-jwt when specific public key formats are used.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2023-48223?

CVE-2023-48223 is a medium-severity vulnerability in nearform fast-jwt, published on 20 Nov 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

fast-jwt provides fast JSON Web Token (JWT) implementation. Prior to version 3.3.2, the fast-jwt library does not properly prevent JWT algorithm confusion for all public key types. The 'publicKeyPemMatcher' in 'fast-jwt/src/crypto.js' does not properly match all common PEM formats for public keys. To exploit this vulnerability, an attacker needs to craft a malicious JWT token containing the HS256 algorithm, signed with the public RSA key of the victim application. This attack will only work if the victim application utilizes a public key containing the `BEGIN RSA PUBLIC KEY` header. Applications using the RS256 algorithm, a public key with a `BEGIN RSA PUBLIC KEY` header, and calling the verify function without explicitly providing an algorithm, are vulnerable to this algorithm confusion attack which allows attackers to sign arbitrary payloads which will be accepted by the verifier. Version 3.3.2 contains a patch for this issue. As a workaround, change line 29 of `blob/master/src/crypto.js` to include a regular expression.

Weakness: CWE-20

Which versions are affected by CVE-2023-48223?

2 open source packages ship an affected version, including fast-jwt. It affects 1 product.

PackageAffectedFixed in
fast-jwt npmAll versions3.3.2
fast-jwt npmAll versions3.3.2

Products include Nearform Fast-Jwt.

How do I fix CVE-2023-48223?

Upgrade fast-jwt to 3.3.2 or later.

Is CVE-2023-48223 being exploited?

There is no known exploitation of CVE-2023-48223 in the wild and no public exploit code.

Public exploit code: 1 proofs of concept on GitHub.

Sources

Also known as GHSA-c2ff-88x2-x9pg.

Is CVE-2023-48223 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free