fast-jwt: Cache Confusion via cacheKeyBuilder Collisions Can Return Claims From a Different Token (Identity/Authorization Mixup)
_NOTE_: While the library exposes a mechanism which could introduce the vulnerability, this issue is created by developer-supplied code and not by the library itself. We will add a warning and some education for users around the possible issues however since the defaults work we will not be updating the library beyond that for this advisory.
Setting up a custom cacheKeyBuilder method which does not properly create unique keys for different tokens can lead to cache collisions. This could cause tokens to be mis-identified during the verification process leading to:
This could result in:
This vulnerability ONLY affects applications that BOTH:
1. Enable caching using the cache option
2. Use custom cacheKeyBuilder functions that can produce collisions
VULNERABLE examples:
```
// Collision-prone: same audience = same cache key
cacheKeyBuilder: (token) => {
const { aud } = parseToken(token)
return aud=${aud}
}
// Collision-prone: grouping by user type
cacheKeyBuilder: (token) => {
const { aud } = parseToken(token)
return aud.includes('admin') ? 'admin-users' : 'regular-users'
}
// Collision-prone: tenant + service grouping
cacheKeyBuilder: (token) => {
const { iss, aud } = parseToken(token)
return ${iss}-${aud}
}
```
SAFE examples:
```
// Default hash-based (recommended)
createVerifier({ cache: true }) // Uses secure default
// Include unique user identifier
cacheKeyBuilder: (token) => {
const { sub, aud, iat } = parseToken(token)
return ${sub}-${aud}-${iat}
}
// No caching (always safe)
createVerifier({ cache: false })
```
To determine if you're affected:
1. Check if caching is enabled: Look for cache: true or cache: <number> in verifier configuration
2. Check for custom cache key builders: Look for cacheKeyBuilder function in configuration
3. Analyze collision potential: Review if your cacheKeyBuilder can produce identical keys for different users/tokens
4. If no custom cacheKeyBuilder: You are NOT affected (default is safe)
Mitigations include:
fast-jwt allows enabling a verification cache through the cache option.
The cache key is derived from the token via cacheKeyBuilder.
When a custom cacheKeyBuilder produces collisions between different tokens, the verifier may return the cached payload of a previous token instead of validating and returning the payload of the current token.
This results in cross-token payload reuse and identity confusion.
Two distinct valid JWTs can be verified successfully but mapped to the same cached entry, causing the verifier to return claims belonging to a different token.
This affects authentication and authorization decisions when applications trust the returned payload.
Affected component
src/verifier.js
Relevant logic:
cache enabled via createCache
cache population via cacheSet
lookup based on cacheKeyBuilder(token)
cached payload returned without re-verification
Impact
Identity / authorization confusion via cache collision.
If two tokens generate the same cache key:
token A is verified → payload stored in cache
token B is verified → cache hit occurs
verifier returns payload from token A instead of B
Observed effect:
subject mismatch
claim mismatch
authorization decision performed on wrong identity
Potential real-world consequences:
user impersonation (logical)
privilege confusion
incorrect RBAC evaluation
gateway / middleware auth inconsistencies
This is especially dangerous when:
cache is enabled (recommended for performance)
custom cacheKeyBuilder is used
identity claims (sub / aud / iss) drive authorization
Root cause
The verifier assumes the cache key uniquely identifies the token and its claims.
However:
cacheKeyBuilder is user-controlled
collisions are not detected
cache entries store decoded payload
cached payload is returned without binding validation
This creates a trust boundary break between:
token → cache key → cached payload
Proof of concept
Environment:
fast-jwt: 6.1.0
Node.js: v24.13.1
PoC:
const { createSigner, createVerifier } = require('fast-jwt')
const sign = createSigner({ key: 'secret' })
// Two distinct tokens
const t1 = sign({ sub: 'userA', aud: 'a
This issue can be reached over the network, attack complexity is low, an attacker needs no privileges on the target. No user interaction is required. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality high, integrity high, availability none.
The score comes from this vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
CVE-2026-35039 is classified as CWE-1289: Improper Validation of Unsafe Equivalence in Input. The product receives an input value that is used as a resource identifier or other type of reference, but it does not validate or incorrectly validates that the input is equivalent to a potentially-unsafe value.
CVE-2026-35039 is recorded against 1 package.
Published on 3 April 2026 and last revised on 17 June 2026. No public exploit is currently recorded for this entry. A vendor advisory or fix has been published. Record sourced from OSV.
github.com (Web)
nvd.nist.gov (Advisory)
github.com (Web)
github.com (Package)
fast-jwt has other advisories on record. If you are patching this one, these are worth checking on the same host:
These advisories are the same class of weakness (CWE-1289: Improper Validation of Unsafe Equivalence in Input) in other software:
Details
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Affected Packages
| Software | From version | Fixed in |
|---|---|---|
| fast-jwt | — | — |
References
Similar Threats
Exploit Protection
CVE-2026-35039 carries CVSS 9.5 Critical rating. BotEraser checks your installation against this and other known CVE records, and blocks IPs associated with exploit activity.
Check My Site For CVE-2026-35039 →No credit card required · Results in minutes
ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.
Stay up to date with the latest from Boteraser.
We use cookies to improve your experience on our site. By using our site, you consent to cookies.
Manage your cookie preferences below:
Essential cookies enable basic functions and are necessary for the proper function of the website.
CloudFlare provides web performance and security solutions, enhancing site speed and protecting against threats.
Service URL: developers.cloudflare.com (opens in a new window)
These cookies are needed for adding comments on this website.
These cookies are used for managing login functionality on this website.
Statistics cookies collect information anonymously. This information helps us understand how visitors use our website.
Google Analytics is a powerful tool that tracks and analyzes website traffic for informed marketing decisions.
Service URL: policies.google.com (opens in a new window)
You can find more information in our Cookie Policy and Privacy Policy.