CVE-2026-35040
fast-jwt: Stateful RegExp (/g or /y) causes non-deterministic allowed-claim validation (logical DoS)
fast-jwt provides fast JSON Web Token (JWT) implementation. Prior to 6.2.1, using certain modifiers on RegExp objects in the allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options in verify functions can cause certain unintended behaviours. This is because some modifiers are stateful and will cause failures in every second verification attempt regardless of the validity of the token provided. Such modifiers are /g (global matching) and /y (sticky matching). This does NOT allow invalid tokens to be accepted, only for valid tokens to be improperly rejected in some configurations. Instead it causes 50% of valid authentication requests to fail in an alternating pattern. This vulnerability is fixed in 6.2.1.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- None
- User interaction
- None
What an attacker can affect
- Confidentiality
- None
- Integrity
- None
- Availability
- Low
Exploit likelihood
What each source reports
CVE List Score used
5.3
fast-jwt: Stateful RegExp (/g or /y) causes non-deterministic allowed-claim validation (logical DoS)
fast-jwt provides fast JSON Web Token (JWT) implementation. Prior to 6.2.1, using certain modifiers on RegExp objects in the allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options in verify functions can cause certain unintended behaviours. This is because some modifiers are stateful and will cause failures in every second verification attempt regardless of the validity of the token provided. Such modifiers are /g (global matching) and /y (sticky matching). This does NOT allow invalid tokens to be accepted, only for valid tokens to be improperly rejected in some configurations. Instead it causes 50% of valid authentication requests to fail in an alternating pattern. This vulnerability is fixed in 6.2.1.
- Record
CVE-2026-35040- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L - Weakness
- CWE-697, CWE-440
- Updated
- 2026-11-02
EUVDEUVD-2026-20898
5.3
fast-jwt provides fast JSON Web Token (JWT) implementation. Prior to 6.2.1, using certain modifiers on RegExp objects in the allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options in verify functions can cause certain unintended behaviours. This is because some modifiers are stateful and will cause failures in every second verification attempt regardless of the validity of the token provided. Such modifiers are /g (global matching) and /y (sticky matching). This does NOT allow invalid tokens to be accepted, only for valid tokens to be improperly rejected in some configurations. Instead it causes 50% of valid authentication requests to fail in an alternating pattern. This vulnerability is fixed in 6.2.1.
- Record
EUVD-2026-20898- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L - Updated
- 2026-11-02
GitHub AdvisoriesGHSA-3j8v-cgw4-2g6q
5.3
fast-jwt: Stateful RegExp (/g or /y) causes non-deterministic allowed-claim validation (logical DoS)
Impact
Using certain modifiers on RegExp objects in the allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options in verify functions can cause certain unintended behaviours. This is because some modifiers are stateful and will cause failures in every second verification attempt regardless of the validity of the token provided.
Such modifiers are:
- /g : Global matching
- /y : Sticky matching
This does NOT allow invalid tokens to be accepted, only for valid tokens to be improperly rejected in some configurations. Instead it causes 50% of valid authentication requests to fail in an alternating pattern, leading to:
- Intermittent user authentication failures
- Potential retry storms in applications
- Operational monitoring alerts
Affected Configurations
This vulnerability ONLY affects applications that:
- Use RegExp objects (not strings) in the allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options
- Use stateful RegExp modifiers such a /g or /y
Example: allowedAud: /abc/g ← IMPACTED Example: allowedAud: "/abc/" ← SAFE
Not Affected
- Applications using string patterns for audience validation (most common)
- Applications using RegExp patterns without stateful modifiers
Assessment Guide
To determine if you're affected:
Check if allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options use RegExp objects (/pattern/ or new RegExp()) If yes, review the pattern for stateful modifiers like /g, /y If no RegExp usage or no stateful modifiers, you are NOT affected
Mitigation Options
While a fix will be coming in the next version of the package you can take steps to mitigate the issue immediately by removing any such modifiers (/g, /y) from the regex.
Summary
fast-jwt accepts RegExp for allowedAud, allowedIss, allowedSub, allowedJti, and allowedNonce.
If the provided regular expression uses the g (global) or y (sticky) flag, verification becomes non-deterministic: the same valid token alternates between acceptance and rejection across successive calls.
This occurs because RegExp.prototype.test() is stateful when g/y is set (it mutates lastIndex), and fast-jwt reuses the same RegExp object without resetting lastIndex.
Affected component
src/verifier.js
ensureStringClaimMatcher() returns the RegExp object directly.
validateClaimValues() performs repeated a.test(v) calls without resetting lastIndex.
Impact
Logical denial-of-service / authentication flapping.
A valid signed JWT can be intermittently rejected.
Causes unpredictable authentication outcomes across repeated verification calls.
Can trigger retry storms and cascading failures in API gateways and authentication middleware.
Affects any deployment that configures allowed* using RegExp and includes g or y flags.
Root cause
validateClaimValues() uses: allowed.some(a => a.test(v))
When a is a RegExp with g or y, a.test() mutates a.lastIndex.
Subsequent calls against the same input can return different results.
Proof of concept
Environment
- fast-jwt: 6.1.0 (repo HEAD)
- Node.js: v24.13.1
PoC const { createSigner, createVerifier } = require('fast-jwt')
const sign = createSigner({ key: 'secret' }) const token = sign({ aud: 'admin', iss: 'issuer' })
function run(name, opts) { const verify = createVerifier({ key: 'secret', ...opts }) console.log('\n==', name) for (let i = 0; i < 8; i++) { try { verify(token); console.log(i, 'PASS') } catch (e) { console.log(i, 'FAIL', e.code || e.message) } } }
run('allowedAud global regex', { allowedAud: /^admin$/g }) run('allowedIss global regex', { allowedIss: /^issuer$/g }) run('control (non-global regex)', { allowedAud: /^admin$/ })
Observed behavior
- allowedAud with
/galternates PASS/FAIL across calls - allowedIss with
/galternates PASS/FAIL across calls - control regex (no g/y) is deterministic and always PASS
Expected behavior
Validation must be deterministic.
The same token under the same verifier…
- Record
GHSA-3j8v-cgw4-2g6q- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L - Weakness
- CWE-440, CWE-697
- Updated
- 2026-11-02
NVD
5.3
fast-jwt provides fast JSON Web Token (JWT) implementation. Prior to 6.2.1, using certain modifiers on RegExp objects in the allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options in verify functions can cause certain unintended behaviours. This is because some modifiers are stateful and will cause failures in every second verification attempt regardless of the validity of the token provided. Such modifiers are /g (global matching) and /y (sticky matching). This does NOT allow invalid tokens to be accepted, only for valid tokens to be improperly rejected in some configurations. Instead it causes 50% of valid authentication requests to fail in an alternating pattern. This vulnerability is fixed in 6.2.1.
- Record
CVE-2026-35040- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L - Weakness
- CWE-440, CWE-697
- Updated
- 2026-11-02
OSV
5.3
fast-jwt: Stateful RegExp (/g or /y) causes non-deterministic allowed-claim validation (logical DoS)
fast-jwt provides fast JSON Web Token (JWT) implementation. Prior to 6.2.1, using certain modifiers on RegExp objects in the allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options in verify functions can cause certain unintended behaviours. This is because some modifiers are stateful and will cause failures in every second verification attempt regardless of the validity of the token provided. Such modifiers are /g (global matching) and /y (sticky matching). This does NOT allow invalid tokens to be accepted, only for valid tokens to be improperly rejected in some configurations. Instead it causes 50% of valid authentication requests to fail in an alternating pattern. This vulnerability is fixed in 6.2.1.
- Record
CVE-2026-35040- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L - Weakness
- CWE-440, CWE-697
- Updated
- 2026-11-02
OSVGHSA-3j8v-cgw4-2g6q
5.3
fast-jwt: Stateful RegExp (/g or /y) causes non-deterministic allowed-claim validation (logical DoS)
Impact
Using certain modifiers on RegExp objects in the allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options in verify functions can cause certain unintended behaviours. This is because some modifiers are stateful and will cause failures in every second verification attempt regardless of the validity of the token provided.
Such modifiers are:
- /g : Global matching
- /y : Sticky matching
This does NOT allow invalid tokens to be accepted, only for valid tokens to be improperly rejected in some configurations. Instead it causes 50% of valid authentication requests to fail in an alternating pattern, leading to:
- Intermittent user authentication failures
- Potential retry storms in applications
- Operational monitoring alerts
Affected Configurations
This vulnerability ONLY affects applications that:
- Use RegExp objects (not strings) in the allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options
- Use stateful RegExp modifiers such a /g or /y
Example: allowedAud: /abc/g ← IMPACTED Example: allowedAud: "/abc/" ← SAFE
Not Affected
- Applications using string patterns for audience validation (most common)
- Applications using RegExp patterns without stateful modifiers
Assessment Guide
To determine if you're affected:
Check if allowedAud, allowedIss, allowedSub, allowedJti, or allowedNonce options use RegExp objects (/pattern/ or new RegExp()) If yes, review the pattern for stateful modifiers like /g, /y If no RegExp usage or no stateful modifiers, you are NOT affected
Mitigation Options
While a fix will be coming in the next version of the package you can take steps to mitigate the issue immediately by removing any such modifiers (/g, /y) from the regex.
Summary
fast-jwt accepts RegExp for allowedAud, allowedIss, allowedSub, allowedJti, and allowedNonce.
If the provided regular expression uses the g (global) or y (sticky) flag, verification becomes non-deterministic: the same valid token alternates between acceptance and rejection across successive calls.
This occurs because RegExp.prototype.test() is stateful when g/y is set (it mutates lastIndex), and fast-jwt reuses the same RegExp object without resetting lastIndex.
Affected component
src/verifier.js
ensureStringClaimMatcher() returns the RegExp object directly.
validateClaimValues() performs repeated a.test(v) calls without resetting lastIndex.
Impact
Logical denial-of-service / authentication flapping.
A valid signed JWT can be intermittently rejected.
Causes unpredictable authentication outcomes across repeated verification calls.
Can trigger retry storms and cascading failures in API gateways and authentication middleware.
Affects any deployment that configures allowed* using RegExp and includes g or y flags.
Root cause
validateClaimValues() uses: allowed.some(a => a.test(v))
When a is a RegExp with g or y, a.test() mutates a.lastIndex.
Subsequent calls against the same input can return different results.
Proof of concept
Environment
- fast-jwt: 6.1.0 (repo HEAD)
- Node.js: v24.13.1
PoC const { createSigner, createVerifier } = require('fast-jwt')
const sign = createSigner({ key: 'secret' }) const token = sign({ aud: 'admin', iss: 'issuer' })
function run(name, opts) { const verify = createVerifier({ key: 'secret', ...opts }) console.log('\n==', name) for (let i = 0; i < 8; i++) { try { verify(token); console.log(i, 'PASS') } catch (e) { console.log(i, 'FAIL', e.code || e.message) } } }
run('allowedAud global regex', { allowedAud: /^admin$/g }) run('allowedIss global regex', { allowedIss: /^issuer$/g }) run('control (non-global regex)', { allowedAud: /^admin$/ })
Observed behavior
- allowedAud with
/galternates PASS/FAIL across calls - allowedIss with
/galternates PASS/FAIL across calls - control regex (no g/y) is deterministic and always PASS
Expected behavior
Validation must be deterministic.
The same token under the same verifier…
- Record
GHSA-3j8v-cgw4-2g6q- CVSS 3.1
- 5.3 Medium
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L - Weakness
- CWE-440, CWE-697
- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
fast-jwtnpm |
before 6.2.1 | 6.2.1 |
History
| Recorded | Changed | Sources |
|---|---|---|
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2026-35040 is a medium vulnerability (CVSS 5.3) in Nearform Fast-jwt, published April 9, 2026. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.40%, the 34th percentile. Fixed in fast-jwt 6.2.1.
References
github.com/nearform/fast-jwt/security/advisories/GHSA-3j8v-cgw4-2g6q
github.com/nearform/fast-jwt/pull/593
github.com/nearform/fast-jwt/commit/18d25904e4617e8753526d1b3ab5a2cccdea726a
github.com/nearform/fast-jwt/releases/tag/v6.2.1
nvd.nist.gov/vuln/detail/CVE-2026-35040
github.com/advisories/GHSA-3j8v-cgw4-2g6q
github.com/CVEProject/cvelistV5/tree/main/cves/2026/35xxx/CVE-2026-35040.json
github.com/nearform/fast-jwt
Left out here: the rest of 2 source descriptions. The JSON record has them.