Improper Input Validation Affecting fast-jwt package, versions <3.3.2


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.08% (35th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Improper Input Validation vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-FASTJWT-6070610
  • published21 Nov 2023
  • disclosed20 Nov 2023
  • creditPinkDraconian

Introduced: 20 Nov 2023

CVE-2023-48223  (opens in a new tab)
CWE-20  (opens in a new tab)

How to fix?

Upgrade fast-jwt to version 3.3.2 or higher.

Overview

fast-jwt is a Fast JSON Web Token implementation

Affected versions of this package are vulnerable to Improper Input Validation due to improperly prevention of JWT algorithm confusion for all public key types. 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.

Note: This attack will only work if the victim application utilizes a public key containing the BEGIN RSA PUBLIC KEY header.

Workaround

Change https://github.com/nearform/fast-jwt/blob/master/src/crypto.js#L29

const publicKeyPemMatcher = '-----BEGIN PUBLIC KEY-----'

To be regex:

const publicKeyPemMatcher = /^-----BEGIN( RSA)? PUBLIC KEY-----/

CVSS Scores

version 3.1