CVE-2026-35041: fast-jwt has a ReDoS when using RegExp in allowed* leading to CPU exhaustion during token verification
⚠️ 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…
Published Apr 9, 2026
Affected packages
fast-jwt
- Ecosystem
- npm
- Affected
- >= 5.0.0, <= 6.2.0
- Fixed in
- 6.2.1
- Check
npm ls fast-jwt
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
⚠️ 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:
- Check ifallowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce use RegExp objects (
/pattern/ornew RegExp()) - If yes, review the pattern for nested quantifiers like
(a+)+,(.*)*, etc. - If no RegExp usage, you are NOT affected
------
<!--StartFragment-->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: a valid signed JWT (post-authentication context) attacker control over the aud claim a vulnerable regex configured by the application Common real-world scenarios shared HS secrets internal JWT issuance microservice authentication OAuth / OIDC custom audiences internal service tokens Proof of Concept Reproduction steps Install fast-jwt Configure verifier with a RegExp in allowedAud Send a valid signed JWT with adversarial aud Attached artifacts poc-suite-redos-fastjwt.js evidence-redos-fastjwt.json Observed behavior Verification CPU time increases from milliseconds to multiple seconds as input length grows. Security Classification CWE-1333: Inefficient Regular Expression CWE-400: Uncontrolled Resource Consumption Class: Authenticated Denial of Service Expected Behavior The library should prevent unbounded CPU work on attacker-controlled claims. Possible mitigations safe-regex validation maximum length enforcement for claims regex complexity limits documentation warning about ReDoS risks when using RegExp-based validation Notes Signature verification occurs before claim validation, therefore this is not a pre-authentication DoS. However, the vulnerability remains exploitable in authenticated or token-bearing contexts and can significantly impact production environments.<!--EndFragment-->
Credited to fasrm, SociableSteve.
References
- https://github.com/nearform/fast-jwt/security/advisories/GHSA-cjw9-ghj4-fwxf
- https://github.com/nearform/fast-jwt/pull/595
- https://github.com/nearform/fast-jwt/commit/b0be0ca161593836a153d5180ca5358ad9b5de94
- https://github.com/nearform/fast-jwt/releases/tag/v6.2.1
- https://nvd.nist.gov/vuln/detail/CVE-2026-35041
- https://github.com/advisories/GHSA-cjw9-ghj4-fwxf
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More npm vulnerabilities
All npm entriesCVE-2026-107719
fast-jwt: Verifier cache accepts expired JWTs without iat.
medium4.2Oct 8, 2026CVE-2026-107720
fast-jwt: createVerifier accepts unsigned JWTs when key is '' or null and algorithms is explicitly set
high7.4Oct 8, 2026CVE-2026-107721
fast-jwt clockTolerance: Infinity silently bypasses both exp and nbf validation (and persists in the verifier cache)
medium5.9Oct 8, 2026CVE-2026-107722
fast-jwt: Incomplete patch of CVE-2026-34950: Non-whitespace key-prefix re-enables RSA→HS256 algorithm confusion
critical9.8Oct 8, 2026CVE-2026-107723
fast-jwt : Silent claim-validator bypass when JWT payload is a JSON array
high8.1Oct 8, 2026CVE-2026-107724
fast-jwt treats raw public JWK JSON as an HMAC secret, enabling HS256 token forgery
high7.4Oct 8, 2026
