# CVE-2026-35040: fast-jwt: Stateful RegExp (/g or /y) causes non-deterministic allowed-claim validation (logical DoS)

> Using stateful RegExp modifiers in fast-jwt validation options causes valid tokens to be rejected, leading to service disruption.

- **Severity:** Medium 5.3 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 9 Apr 2026
- **Updated:** 13 Apr 2026
- **Also known as:** GHSA-3j8v-cgw4-2g6q

## What is CVE-2026-35040?

CVE-2026-35040 is a medium-severity denial of service vulnerability in nearform fast-jwt, published on 9 Apr 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

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.

Weakness: CWE-697 (Incorrect Comparison), CWE-440 (Expected Behavior Violation)

## Which versions are affected by CVE-2026-35040?

2 open source packages ship an affected version, including fast-jwt. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `fast-jwt` | npm | All versions | 6.2.1 |
| `fast-jwt` | npm | All versions | 6.2.1 |

Products: Nearform Fast-Jwt.

## How do I fix CVE-2026-35040?

Upgrade fast-jwt to 6.2.1 or later.

## Is CVE-2026-35040 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-35040 exists.

## Other vulnerabilities in nearform fast-jwt

- [CVE-2026-34950](https://insights.sbomify.com/CVE-2026-34950/): fast-jwt has an incomplete fix for CVE-2023-48223: JWT Algorithm Confusion via Whitespace-Prefixed RSA Public Key (critical 9.1)
- [CVE-2026-35039](https://insights.sbomify.com/CVE-2026-35039/): fast-jwt: Cache Confusion via cacheKeyBuilder Collisions Can Return Claims From a Different Token (Identity/Authorization Mixup) (critical 9.1)
- [CVE-2026-35042](https://insights.sbomify.com/CVE-2026-35042/): fast-jwt accepts unknown `crit` header extensions (RFC 7515 §4.1.11 MUST violation) (high 7.5)
- [CVE-2023-48223](https://insights.sbomify.com/CVE-2023-48223/): fast-jwt JWT Algorithm Confusion (medium 5.9)
- [CVE-2026-35041](https://insights.sbomify.com/CVE-2026-35041/): ReDoS in fast-jwt when using RegExp in allowed* leading to CPU exhaustion during token verification (medium 4.2)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-35040 and fix it if it is affected.

What it is: CVE-2026-35040 is a medium-severity denial of service vulnerability in nearform fast-jwt, published on 9 Apr 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-35040 exists.

Affected packages and fixed versions:
- fast-jwt (npm): affected all versions; fixed in 6.2.1
- fast-jwt (npm): affected all versions; fixed in 6.2.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-35040/ (Markdown: https://insights.sbomify.com/CVE-2026-35040/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-35040
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-35040
- OSV: https://osv.dev/vulnerability/CVE-2026-35040

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-35040/
Summaries are generated and may contain mistakes; the official description above is the record.
