# CVE-2026-34950: NearForm fast-jwt algorithm confusion via whitespace-prefixed RSA public key

Source: https://junglewise.ai/threats/cve-2026-34950-nearform-fast-jwt-algorithm-confusion-via-whitespace-prefixed-rsa  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-04-06. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2026-34950 · Severity: critical · CVSS 9.1 · Published 2026-04-06

fast-jwt is a Node.js library for signing and verifying JSON Web Tokens (JWTs). The library's incomplete fix for a prior algorithm confusion vulnerability allows attackers to forge authentication tokens when RSA public keys contain leading whitespace—a common occurrence when keys are loaded from databases or configuration files. An attacker can forge tokens with arbitrary claims (e.g., elevated privileges) without knowing the private key, leading to authentication bypass and unauthorized access.

Technologies: [Nearform Fast-Jwt](https://junglewise.ai/threats/technologies/nearform-fast-jwt), [fast-jwt (npm)](https://junglewise.ai/threats/technologies/fast-jwt). Vendors: [Nearform](https://junglewise.ai/threats/vendors/nearform), [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

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

**How severe is CVE-2026-34950?** Critical severity, with a CVSS score of 9.1, published 6 April 2026.

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

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

**How is CVE-2026-34950 attacked?** It is attacked over the network.

**Am I affected by CVE-2026-34950?** Check whether you run Nearform Fast-Jwt or 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 6.2.0 or later

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


## Technical details

This is a JWT algorithm confusion vulnerability caused by incomplete input validation in the publicKeyPemMatcher regex. The root cause is inconsistency: the private key detection path calls .trim() on the input before regex matching, but the public key detection path does not. When an RSA public key string has leading whitespace, the regex anchor (^) fails to match the "-----BEGIN" marker, causing the library to misclassify the RSA public key as an HMAC secret. An attacker with access to the public key can then forge HS256 tokens using the public key as the HMAC secret, bypassing authentication. The attack requires network access to a vulnerable endpoint; no user interaction or prior authentication is needed. Leading whitespace in PEM keys is common in real-world deployments (database text columns, YAML multiline strings, environment variables, copy-paste). The vulnerability was patched in version 6.2.0 by adding .trim() to the public key matching path.

## Affected products

- NearForm fast-jwt <= 6.1.0

## Identifiers

- CVE-2026-34950
- GHSA-mvf2-f6gm-w987

## Timeline

- 2026-04-02: advisory
- 2026-04-02: patched: patched in version 6.2.0

## References

- [https://github.com/nearform/fast-jwt/security/advisories/GHSA-mvf2-f6gm-w987](https://github.com/nearform/fast-jwt/security/advisories/GHSA-mvf2-f6gm-w987)

## 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)
