/

CVE-2026-44351

Severity:

CRITICAL RISK

(9.1)

Authentication Bypass in fast-jwt Async Key Resolver

CVE-2026-44351

Deferred

Vulnerability type

Category:

Authentication Bypass

CWE:

CWE-287, CWE-326, CWE-1391

Impact:

Authentication and Authorization Bypass via Forged JWTs

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A flaw in fast-jwt's async key-resolver logic allows empty strings from a JWKS-style resolver to be treated as valid secret keys, causing tokens to be verified using an HMAC with an effectively empty key.

An unauthenticated attacker who can control the JWT can forge arbitrary tokens by computing a valid HMAC over attacker-chosen claims, leading to full authentication bypass wherever fast-jwt is used for access control.

Affected context

This vulnerability appears in Node.js applications that:

  • Use fast-jwt prior to 6.2.4 for JWT verification, and
  • Rely on an async key-resolver to supply the verification key (for example, from JWKS or a key map), and
  • Implement a fallback such as keys[decoded.header.kid] || '', allowing the resolver to return an empty string when a key ID is missing or not found.

In such configurations, fast-jwt converts the empty string into a zero-length Buffer and derives an HMAC secret key from it, unintentionally accepting signatures generated with an effectively empty key as valid.

Exploit preconditions

  • Attack surface: Any endpoint or service that accepts JWTs and verifies them using fast-jwt's async key resolver.
  • Required access: No prior authentication is required; an attacker only needs the ability to submit arbitrary JWTs (e.g., Authorization header, cookies, query parameters).
  • Trigger point: The key resolver returns an empty string (such as via keys[decoded.header.kid] || '' when the kid is unknown or the key map is empty).
  • Why exploitation is possible: fast-jwt treats the empty string as a valid secret, constructs an HMAC key from it, assigns default allowedAlgorithms = ['HS256','HS384','HS512'], and verifies the signature using HMAC with this empty key. Since the HMAC computation is deterministic and the key is effectively empty, attackers can generate matching signatures for any header and payload they choose.

Why this happens

The underlying flaw is a combination of improper authentication enforcement and insecure key handling:

  • Improper Authentication (CWE-287): The library accepts tokens as authentic based on a cryptographic check that can succeed with an unintended, trivially guessable key (the empty string), allowing bypass of intended authentication logic.
  • Inadequate Cryptographic Strength (CWE-326) / Weak or Null Keys (CWE-1391): An empty string returned by the key resolver is implicitly accepted as a valid secret key. This breaks the assumption that verification keys are strong, secret values and effectively reduces the verification secret to a known null-like key.

Conceptually, the bug stems from failing to enforce that key-resolver outputs are non-empty, valid cryptographic keys and from silently falling back to a default HMAC-based verification path with an invalid key, rather than rejecting the token outright.

Potential impact

  • Attackers can forge JWTs that the application accepts as valid, without knowing any real signing keys.
  • Arbitrary impersonation of users by setting sub, email, or other identity claims to attacker-chosen values.
  • Escalation to administrative roles by injecting privileged claims (e.g., admin: true, high-privilege scopes/roles).
  • Bypass of API gateway or backend access controls that rely on JWT verification for authorization decisions.
  • Potential lateral movement within distributed systems where JWTs are used for service-to-service trust.

General mitigation guidance

Effective mitigation focuses on enforcing strict key validity and hardening JWT verification flows:

  • Ensure that key resolvers never return empty strings, null, or other invalid values; explicitly treat unknown or missing kid values as verification failures.
  • Introduce validation logic that rejects tokens if the derived verification key is empty, too short, or otherwise does not meet cryptographic strength requirements.
  • Avoid permissive fallbacks such as keys[decoded.header.kid] || ''; instead, fail closed when a key cannot be resolved.
  • Constrain allowed algorithms explicitly and avoid automatic inference of HMAC algorithms when keys are ambiguous.
  • Apply least-privilege patterns around JWT usage: separate tokens used for authentication from those used for non-critical metadata, and limit the authority conferred by individual tokens.
  • Where possible, centralize JWT verification in a well-reviewed component and treat any key resolution anomaly as a hard error.

How teams detect issues like this

Detection can leverage both code-level analysis and behavioral monitoring:

  • Static analysis and code review:
  • Search for fast-jwt usage with async key resolvers and inspect for fallbacks like || '', || null, or similar patterns returning empty or default values.
  • Review key-resolution logic for cases where unknown kid values or missing keys do not immediately cause verification failure.
  • Check for implicit acceptance of default allowedAlgorithms driven by resolver outputs, rather than explicit configuration.
  • Configuration and policy checks:
  • Enforce internal development policies that prohibit empty, zero-length, or trivially weak keys from being used in JWT verification.
  • Use automated linters or security scanners to flag JWT verification code that does not validate resolver outputs.
  • Runtime monitoring:
  • Log JWT verification errors and include the resolved kid/key metadata (without exposing secrets) to identify suspicious patterns such as frequent verification with missing or unknown kid values.
  • Look for anomalous authentication events, such as sudden surges in logins for high-privilege accounts or tokens with unusual claim combinations being accepted.

Sources

SourceLink
github.comgithub.com/nearform/fast-jwt/security/advisories/GHSA-gmvf-9v4p-v8jc

Frequently asked

questions

Yes. Any remote client that can send a JWT to an affected service can exploit this issue, as long as the service uses the vulnerable fast-jwt async key-resolver pattern that may yield an empty key.

No prior access is required. An attacker can craft tokens from scratch, choosing arbitrary headers and payloads, and then compute a matching HMAC with the effectively empty key that the verifier will accept.

The safest pattern is to fail closed when key resolution does not return a valid, strong key. This means rejecting tokens outright if the resolver cannot find a key, returns an empty or invalid value, or if the algorithm/key combination does not explicitly match a configured, trusted set.

Design JWT verification with strict assumptions: resolvers must return validated keys, missing keys must cause failures, and algorithms must be explicitly controlled. Combine this with code reviews aimed at key-handling logic, use of mature token libraries with secure defaults, and automated checks that detect weak or null-key patterns before deployment.

Find out what's already
exploitable in your codebase.