fast-jwt: Empty HMAC secret accepted via async key resolver - JWT auth bypass
fast-jwt provides fast JSON Web Token (JWT) implementation. Prior to 6.2.4, 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. This vulnerability is fixed in 6.2.4.
Problem Types
| Type | CWE ID | Description |
|---|
| CWE | CWE-287 | CWE-287: Improper Authentication |
| CWE | CWE-326 | CWE-326: Inadequate Encryption Strength |
| CWE | CWE-1391 | CWE-1391: Use of Weak Credentials |
Type: CWE
Description: CWE-287: Improper Authentication
Type: CWE
Description: CWE-326: Inadequate Encryption Strength
Type: CWE
Description: CWE-1391: Use of Weak Credentials
Metrics
| Version | Base score | Base severity | Vector |
|---|
| 3.1 | 9.1 | CRITICAL | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N |
Version: 3.1
Base score: 9.1
Base severity: CRITICAL
Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N