CVE-2026-34950 Overview
CVE-2026-34950 is a critical cryptographic vulnerability in the fast-jwt library, a popular JSON Web Token (JWT) implementation for Node.js applications. The vulnerability exists in version 6.1.0 and earlier, where the publicKeyPemMatcher regex in fast-jwt/src/crypto.js uses a ^ anchor that can be bypassed by introducing leading whitespace in the key string. This flaw re-enables the exact same JWT algorithm confusion attack that was previously patched in CVE-2023-48223.
Critical Impact
Attackers can exploit this regex bypass to perform JWT algorithm confusion attacks, potentially forging valid tokens and bypassing authentication mechanisms in affected applications.
Affected Products
- fast-jwt versions 6.1.0 and earlier
- Node.js applications using vulnerable fast-jwt versions for JWT verification
- Services relying on fast-jwt for authentication and authorization
Discovery Timeline
- 2026-04-06 - CVE CVE-2026-34950 published to NVD
- 2026-04-07 - Last updated in NVD database
Technical Details for CVE-2026-34950
Vulnerability Analysis
This vulnerability falls under CWE-327 (Use of a Broken or Risky Cryptographic Algorithm) and represents a regression of a previously patched security issue. The core problem lies in how the publicKeyPemMatcher regex validates PEM-formatted public keys during JWT verification.
The regex pattern uses a ^ anchor to match the beginning of the key string. However, this anchor only matches the absolute start of the string and is defeated when any leading whitespace characters (spaces, tabs, newlines) precede the actual PEM header. When the regex fails to match, the library may fall back to alternative key handling logic that enables algorithm confusion attacks.
In a JWT algorithm confusion attack, an attacker can trick the verification process into using the wrong algorithm. For instance, an attacker might craft a token signed with the HMAC algorithm using the public key as the secret, while the server expects an RSA-signed token. If the key validation is bypassed, the server may incorrectly verify the malicious token as valid.
Root Cause
The root cause is improper input validation in the publicKeyPemMatcher regex within fast-jwt/src/crypto.js. The regex relies on the ^ anchor for string start matching without accounting for leading whitespace characters that may be present in user-supplied or externally-sourced key material. This oversight creates a bypass condition where malformed keys with leading whitespace evade the intended validation logic.
Attack Vector
The attack vector is network-based and requires no authentication or user interaction. An attacker with knowledge of the application's public key can:
- Craft a JWT token with an alg header claiming symmetric algorithm (e.g., HS256)
- Prepend whitespace to the public key material to bypass the publicKeyPemMatcher regex
- Sign the token using the public key as an HMAC secret
- Submit the forged token to the target application
- The vulnerable validation logic may accept the malicious token as legitimate
The vulnerability can be exploited through the JWT verification process where an attacker-controlled token is submitted to an application using vulnerable versions of fast-jwt. The algorithm confusion attack allows authentication bypass and potential privilege escalation depending on the application's use of JWT claims.
Detection Methods for CVE-2026-34950
Indicators of Compromise
- Unexpected JWT tokens with mismatched algorithm headers (e.g., HS256 instead of RS256)
- Authentication logs showing successful validation of tokens with suspicious algorithm claims
- Application logs indicating key parsing anomalies or regex matching failures
- Unusual access patterns following authentication with forged credentials
Detection Strategies
- Audit application dependencies for fast-jwt versions 6.1.0 and earlier using npm audit or similar tools
- Implement monitoring for JWT tokens where the alg header differs from expected algorithm configurations
- Review authentication logs for successful logins that bypass normal verification patterns
- Deploy SentinelOne Singularity to detect exploitation attempts targeting Node.js applications
Monitoring Recommendations
- Enable verbose logging for JWT verification operations to capture algorithm and key processing details
- Monitor for authentication events with anomalous algorithm parameters in JWT headers
- Set up alerts for dependency version changes and security advisory notifications for fast-jwt
- Implement runtime application monitoring to detect unexpected cryptographic operation patterns
How to Mitigate CVE-2026-34950
Immediate Actions Required
- Update fast-jwt to a patched version that addresses the regex bypass vulnerability
- Review application configurations to ensure explicit algorithm specification during JWT verification
- Audit existing authentication logs for potential exploitation attempts
- Implement allowlist-based algorithm validation that rejects unexpected algorithm claims
Patch Information
The vulnerability is tracked in the GitHub Security Advisory GHSA-mvf2-f6gm-w987. Affected organizations should consult the security advisory for the latest patched version and upgrade instructions. The patch addresses the regex pattern to properly handle or reject keys with leading whitespace characters.
Workarounds
- Configure explicit algorithm restrictions in JWT verification options to prevent algorithm confusion
- Implement pre-validation of PEM key material to strip or reject inputs with leading whitespace
- Use middleware to validate JWT alg header matches expected algorithm before verification
- Consider implementing additional signature verification layers independent of fast-jwt
# Check for vulnerable fast-jwt versions in your project
npm ls fast-jwt
# Update to the latest patched version
npm update fast-jwt
# Run security audit to identify vulnerable dependencies
npm audit
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


