# CVE-2023-48223: fast-jwt JWT algorithm confusion

Source: https://junglewise.ai/threats/cve-2023-48223-fast-jwt-jwt-algorithm-confusion  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2023-11-20. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2023-48223 · Severity: low · CVSS 3.1 · Published 2023-11-20

fast-jwt is a JavaScript library used to create and verify JSON Web Tokens (JWTs), which are commonly used for API authentication. The library incorrectly validates public key formats, allowing an attacker to forge valid JWT tokens by switching the signing algorithm from RS256 to HS256 and signing with the public key itself. This can enable account takeover or privilege escalation if applications don't explicitly restrict the allowed algorithms.

Technologies: [fast-jwt (npm)](https://junglewise.ai/threats/technologies/fast-jwt). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2023-48223 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2023-48223 being exploited in the wild.

**How severe is CVE-2023-48223?** Low severity, with a CVSS score of 3.1, published 20 November 2023.

**Which products and versions are affected?** fast-jwt (npm) SEMVER:introduced=0,fixed=3.3.2.

**Is there a fix for CVE-2023-48223?** Yes. fast-jwt (npm): upgrade to 3.3.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2023-48223 attacked?** It is attacked over the network.

**Am I affected by CVE-2023-48223?** Check whether you run fast-jwt (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- fast-jwt (npm): upgrade to 3.3.2 or later

  ```sh
  npm install fast-jwt@3.3.2
  ```


## Technical details

The vulnerability is an algorithm confusion attack stemming from improper input validation (CWE-20) in the publicKeyPemMatcher regular expression in fast-jwt/src/crypto.js. The matcher fails to recognize all valid PEM public key formats, specifically those with the "BEGIN RSA PUBLIC KEY" header. An attacker who obtains the application's public key (via token inspection or public endpoints) can craft a malicious JWT with the HS256 algorithm, sign it with the public key, and submit it to applications that call the verify function without explicitly specifying the allowed algorithm. No authentication or user interaction is required; only network access to the JWT endpoint is needed. The attack only succeeds on applications using RS256 with RSA public key format and not explicitly restricting algorithms. Patched in version 3.3.2.

## Affected products

- NearForm fast-jwt < 3.3.2

## Identifiers

- CVE-2023-48223
- GHSA-c2ff-88x2-x9pg

## Timeline

- 2023-11-20: disclosed
- 2023-11-20: patched: Version 3.3.2 released

## References

- [https://github.com/nearform/fast-jwt/security/advisories/GHSA-c2ff-88x2-x9pg](https://github.com/nearform/fast-jwt/security/advisories/GHSA-c2ff-88x2-x9pg)

## Related threats

- [fast-jwt JWK JSON HMAC secret misclassification in HS256 verification](https://junglewise.ai/threats/cve-2026-107724-fast-jwt-treats-raw-public-jwk-json-as-an-hmac-secret-enabling)
- [fast-jwt claim-validator bypass with JSON array payload](https://junglewise.ai/threats/cve-2026-107723-fast-jwt-silent-claim-validator-bypass-when-jwt-payload-is-a)
- [fast-jwt incomplete RSA-to-HS256 algorithm confusion fix](https://junglewise.ai/threats/cve-2026-107722-fast-jwt-incomplete-patch-of-non-whitespace-key-prefix-re)
- [fast-jwt clockTolerance validation bypass in expiry and not-before checks](https://junglewise.ai/threats/cve-2026-107721-fast-jwt-clocktolerance-infinity-silently-bypasses-both-exp-and)
- [fast-jwt signature verification bypass with null/empty key](https://junglewise.ai/threats/cve-2026-107720-fast-jwt-createverifier-accepts-unsigned-jwts-when-key-is-or)
