GitHub Advisoryadvisory · npm
GHSA-cjw9-ghj4-fwxf fast-jwt has a ReDoS when using RegExp in allowed* leading to CPU exhaustion during token verification
MEDIUM
Official page ↗
- Aliases
- CVE-2026-35041
- Ecosystem
- npm
- Packages
- fast-jwt
- Severity
- Moderate
- CVSS vector
- CVSS:3.1/AV:N/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:H
- Weaknesses
- CWE-1333
- Reviewed
- 2026-04-09
Affected packages
• npm fast-jwt: >= 5.0.0, < 6.2.1 → fixed in 6.2.1
Description
⚠️ IMPORTANT CLARIFICATIONS
### Affected Configurations
This vulnerability ONLY affects applications that:
• Use RegExp objects (not strings) in the allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options
• Configure patterns susceptible to catastrophic backtracking
• Example: `allowedAud: /^(a+)+X$/` ← VULNERABLE
• Example: `allowedAud: "api.company.com"` ← SAFE
### Not Affected
• Applications using string patterns for audience validation (most common)
• Applications using safe RegExp patterns without nested quantifiers
• Default fast-jwt configurations
### Assessment Guide
To determine if you're affected:
1. Check ifallowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce use RegExp objects (`/pattern/` or `new RegExp()`)
2. If yes, review the pattern for nested quantifiers like `(a+)+`, `(.*)*`, etc.
3. If no RegExp usage, you are NOT affected
------
Summary
A denial-of-service condition exists in fast-jwt when the allowedAud verification option is configured using a regular expression.
Because the aud claim is attacker-controlled and the library evaluates it against the supplied RegExp, a crafted JWT can trigger catastrophic backtracking in the JavaScript regex engine, resulting in significant CPU consumption during verification.
This occurs with a validly signed JWT, making the issue exploitable in authenticated contexts such as:
API gateways
authentication middleware
service-to-service communication
OAuth / OIDC token validation pipelines
Affected Component
Library: fast-jwt
Version tested: 6.1.0
Runtime: Node.js v24.13.1
Feature: claim validation using allowedAud: RegExp
Impact
CPU exhaustion / Denial of Service
A crafted JWT causes verification to take multiple seconds per request due to catastrophic regex backtracking.
Measured verification times
Input size (n) | Verification time
-- | --
24 | ~123 ms
28 | ~1.97 s
30 | ~7.85 s
This is sufficient to:
block Node.js event loop threads
degrade API throughput
cause cascading service failures
increase serverless execution costs
saturate authentication infrastructure
Root Cause
The library allows regular expressions in claim validation:
allowedAud: /^(a+)+X$/
The aud claim is attacker-controlled:
aud = "a".repeat(n) + "Y"
This creates catastrophic backtracking in the JavaScript regex engine.
Verification time grows exponentially as input length increases.
Exploitability
Attack requires:
<p data-start="1927" data-…
Related
Alias · CVE (1)
- CVE-2026-35041 fast-jwt provides fast JSON Web Token (JWT) implementation. vulnerability
Weakness · CWE (1)
- CWE-1333 Inefficient Regular Expression Complexity weakness
References
- https://github.com/nearform/fast-jwt/security/advisories/GHSA-cjw9-ghj4-fwxf web
- https://nvd.nist.gov/vuln/detail/CVE-2026-35041 advisory
- https://github.com/nearform/fast-jwt/pull/595 web
- https://github.com/nearform/fast-jwt/commit/b0be0ca161593836a153d5180ca5358ad9b5de94 web
- https://github.com/nearform/fast-jwt package
- https://github.com/nearform/fast-jwt/releases/tag/v6.2.1 web