PT-2023-30740 · Fast-Jwt · Fast-Jwt

Pinkdraconian

·

Published

2023-11-20

·

Updated

2026-04-06

·

CVE-2023-48223

CVSS v3.1

5.9

Medium

VectorAV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N
Name of the Vulnerable Software and Affected Versions fast-jwt versions prior to 3.3.2
Description 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 issue, 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.
Recommendations For versions prior to 3.3.2, update to version 3.3.2 to resolve the issue. As a temporary workaround, change line 29 of fast-jwt/src/crypto.js to include a regular expression: const publicKeyPemMatcher = /^-----BEGIN( RSA)? PUBLIC KEY-----/. Restrict access to the verify function to minimize the risk of exploitation until the issue is resolved.

Exploit

Fix

RCE

Weakness Enumeration

Related Identifiers

CVE-2023-48223
GHSA-C2FF-88X2-X9PG

Affected Products

Fast-Jwt