CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-107722

CVE-2026-107722: Algorithm Confusion via Non-Whitespace Prefix Bypass in fast-jwt

Amit Schendel
Amit Schendel
Senior Security Researcher

Oct 9, 2026·5 min read·32 visits

Executive Summary (TL;DR)

Incomplete key sanitization in fast-jwt allows RSA-to-HMAC algorithm confusion, enabling complete authentication bypass.

A critical cryptographic vulnerability in fast-jwt versions 6.2.x prior to 6.3.0 allows unauthenticated remote attackers to execute an asymmetric-to-symmetric algorithm confusion attack due to incomplete validation of leading non-whitespace prefixes.

Vulnerability Overview

The fast-jwt library is a high-performance JSON Web Token implementation designed for Node.js environments. In versions 6.2.x prior to 6.3.0, it contains a critical vulnerability that allows asymmetric-to-symmetric algorithm confusion. This attack vector allows an unauthenticated remote attacker to bypass cryptographic signature verification and gain unauthorized access to target applications.

The vulnerability is rooted in how the library auto-detects the format of the key supplied to the verifier. When a verifier is initialized without an explicit, restrictive algorithm allowlist, it evaluates the key format to determine whether to perform asymmetric (RS*/ES*) or symmetric (HS*) signature verification. Because the auto-detection routine depends on matching anchored regular expressions, the presence of specific non-whitespace leading prefixes causes the parser to fail back to symmetric validation.

An attacker who knows or can obtain the server public key can exploit this fallback. By signing a forged token with the public key as the shared HMAC secret, the attacker triggers verification using the symmetric pipeline. This completely invalidates the integrity guarantees of the token and allows full system access.

Root Cause Analysis

The root cause of CVE-2026-107722 is an incomplete patch for an earlier key-parsing vulnerability, CVE-2026-34950. The previous security fix attempted to protect the anchored regular expressions by calling String.prototype.trim() on the key input before matching headers. However, the standard ECMAScript trim operation only removes whitespace characters, leaving any leading non-whitespace characters intact.

Key detection regular expressions are anchored to the start of the string using the '^' character. For example, the parser identifies public keys via /^-----BEGIN(?: (RSA))? PUBLIC KEY-----/. When the key contains non-whitespace prefixes—such as database comments, control characters, or protocol headers—the regular expression fails to match.

Because the anchored check fails, the library assumes the key is not a PEM-formatted asymmetric key. Instead of throwing an error or rejecting the invalid input, the verification engine falls back to treating the key as a raw, symmetric HMAC shared secret. The entire prefixed public key string is then registered as the symmetric HMAC key.

Code Analysis

In vulnerable versions of src/crypto.js, the key sanitization code relies entirely on standard string trimming:

// Vulnerable logic in fast-jwt < 6.3.0
function performDetectPublicKeyAlgorithms(key) {
  const trimmedKey = key.trim()
  const publicKeyPemMatch = trimmedKey.match(publicKeyPemMatcher) 
  // If key begins with non-whitespace prefix, publicKeyPemMatch is null
  if (!publicKeyPemMatch) {
    return hsAlgorithms // Falls back to symmetric HMAC algorithms
  }
}

In the patched version (v6.3.0), the library introduces a centralized, non-anchored PEM locator function. This function scans the entire key string to identify the position of the standard PEM boundary, preventing bypasses caused by arbitrary prefixes:

// Patched logic in fast-jwt 6.3.0
const pemBeginMatcher = /-----BEGIN [A-Z0-9 ]+?-----/
 
function locatePem(trimmedKey) {
  const pemStart = trimmedKey.search(pemBeginMatcher)
  if (pemStart === -1) {
    return { pem: null, isRawSecret: true }
  }
  return { pem: trimmedKey.slice(pemStart), isRawSecret: false }
}

The update ensures that any string containing a valid PEM block is correctly isolated and processed as an asymmetric key, regardless of preceding data. It also throws a definitive TokenError if a PEM header is recognized but is unsupported, eliminating silent fallbacks.

Exploitation Methodology

An attacker targets applications that do not enforce explicit verification algorithms. If the application loads a public key containing a leading comment or non-whitespace prefix, the attacker can leverage the algorithm confusion flaw.

The attacker retrieves the public key and generates a malicious JWT. The header is configured with the 'alg' field set to 'HS256' to instruct the server to use symmetric verification. The payload is configured with arbitrary claims, such as administrative access privileges.

The attacker signs the token using HMAC-SHA256, utilizing the full, prefixed public key string as the shared secret key. When the application receives the token, the fast-jwt verifier evaluates the header algorithm as 'HS256', resolves the verification key as a symmetric secret due to the failed PEM check, and verifies the signature successfully.

Impact Assessment

The impact of successful exploitation is a complete compromise of the token validation mechanism. An attacker can forge JWTs containing arbitrary identity claims and permissions, bypassing authentication and authorization controls without possessing the server private key.

This flaw is classified under CWE-347 (Improper Verification of Cryptographic Signature) and has a CVSS v3.1 base score of 9.8. Exploitation is highly reliable, requiring no user interaction and low attack complexity. Applications that automatically load public keys from external databases or environment configuration strings are particularly exposed if those inputs contain metadata prefixes.

Remediation and Mitigation

To resolve this vulnerability, upgrade fast-jwt to version 6.3.0 or higher. The updated package eliminates the vulnerable validation paths by extracting the PEM block correctly using the non-anchored locatePem implementation.

As a defense-in-depth measure, developers must configure verifiers with an explicit list of allowed algorithms. This completely disables key auto-detection and prevents algorithm-confusion bypasses by rejecting any token signed with an unexpected algorithm:

const { createVerifier } = require('fast-jwt')
const fs = require('fs')
 
const publicKey = fs.readFileSync('public.pem', 'utf8')
 
// Secure configuration bypassing auto-detection
const verify = createVerifier({
  key: publicKey,
  algorithms: ['RS256']
})

Official Patches

nearformPull Request #632 fixing non-whitespace prefix parsing

Fix Analysis (1)

Technical Appendix

CVSS Score
9.8/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Affected Systems

fast-jwt Node.js library

Affected Versions Detail

Product
Affected Versions
Fixed Version
fast-jwt
nearform
>= 6.2.0 < 6.3.06.3.0
AttributeDetail
CWE IDCWE-347
Attack VectorNetwork (AV:N)
CVSS Score9.8 (Critical)
ImpactComplete Authentication Bypass
Exploit StatusProof-of-Concept (PoC) available in test suite
KEV StatusNot Listed

MITRE ATT&CK Mapping

T1606.001Forge Web Credentials: Web Tokens
Credential Access
T1556Modify Authentication Process
Defense Evasion
CWE-347
Improper Verification of Cryptographic Signature

The application does not properly verify the cryptographic signature of the JSON Web Token (JWT) due to algorithm confusion, allowing unauthorized claims to be trusted as authentic.

Known Exploits & Detection

GitHub Security AdvisoryGHSA-ww5h-9m49-7xx4: Algorithm Confusion via Non-Whitespace Prefix Bypass in fast-jwt

Vulnerability Timeline

Vulnerability reported and PR #632 created
2026-07-27
Patch merged and version 6.3.0 released
2026-07-28
CVE-2026-107722 officially published
2026-10-08

References & Sources

  • [1]GitHub Security Advisory GHSA-ww5h-9m49-7xx4
  • [2]GitHub Pull Request #632
  • [3]Fix Commit d96bbc6
Related Vulnerabilities
CVE-2026-34950

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•2 days ago•CVE-2026-58254
6.5

CVE-2026-58254: Authorization Bypass in NATS Server Message Tracing for Leaf Node Connections

NATS Server prior to versions 2.12.8 and 2.14.3 contains an incorrect authorization vulnerability (CWE-863) in its message tracing subsystem. When evaluating whether a connection is permitted to publish trace events to a destination subject specified in the Nats-Trace-Dest header, the server only checks standard client permissions and omits permission checks for leaf node connections. This allows a connected leaf node operator with restricted publishing privileges to emit internal trace events to unauthorized subjects and suppress standard message delivery using the Nats-Trace-Only header.

Alon Barad
Alon Barad
11 views•10 min read
•2 days ago•CVE-2026-63341
7.5

CVE-2026-63341: Unauthenticated Denial of Service via Unbounded Topic Depth in Aedes MQTT Broker

CVE-2026-63341 is a high-severity Denial of Service (DoS) vulnerability in the Aedes MQTT broker for Node.js affecting all versions prior to 1.1.1. The flaw stems from missing input validation on the hierarchical depth of incoming MQTT topic strings before they are passed to the underlying topic-matching engine, qlobber. Because qlobber enforces a hardcoded limit of 100 topic levels and throws a synchronous exception when this threshold is exceeded, an attacker can send a single MQTT packet containing 101 or more forward-slash-separated levels to trigger an uncaught exception that immediately terminates the Node.js broker process.

Alon Barad
Alon Barad
16 views•12 min read
•2 days ago•CVE-2026-61725
6.1

CVE-2026-61725: Path Traversal and Arbitrary File Overwrite in sevenz-rust2

CVE-2026-61725 is a path traversal vulnerability (CWE-22) in the sevenz-rust2 Cargo package prior to version 0.21.1. The vulnerability occurs because the decompression utility fails to validate or sanitize archive entry filenames before joining them with the destination directory path via std::path::Path::join. An attacker who supplies a crafted 7z archive containing parent directory traversal sequences or absolute paths can write or overwrite arbitrary files on the host filesystem with the privileges of the extracting process.

Alon Barad
Alon Barad
6 views•12 min read
•2 days ago•CVE-2026-77309
8.8

CVE-2026-77309: Unauthenticated Remote Code Execution in NASA-AMMOS AIT-GUI via Incomplete File Cleanup and Path Traversal

CVE-2026-77309 (GHSA-jrjx-9jjw-747m) is a high-severity unauthenticated remote code execution vulnerability affecting NASA-AMMOS AIT-GUI versions 1.0.0 through 2.5.0. The flaw results from chaining an incomplete file cleanup error in the telemetry query endpoint (/tlm/query) with a directory traversal flaw in the script execution endpoint (/script/run). An attacker on an adjacent network can stage arbitrary Python statements into a static file on disk and execute that file under the privileges of the AIT-GUI web server process.

Amit Schendel
Amit Schendel
16 views•10 min read
•2 days ago•CVE-2026-77332
2.3

CVE-2026-77332: Surfaced-Memory Envelope Injection and Stored Prompt Injection in memtomem-stm

A vulnerability classified under CWE-116 (Improper Encoding or Escaping of Output) exists in memtomem-stm versions 0.1.0 through 0.1.33. The software acts as a Model Context Protocol (MCP) short-term memory proxy gateway for AI agent architectures. When surfacing retrieved memories and scratchpad items into downstream Large Language Model (LLM) context envelopes, the SurfacingFormatter component fails to properly sanitize untrusted memory attributes. An attacker with the ability to plant untrusted content into the agent's long-term or working memory store can inject arbitrary structural delimiters, close the <surfaced-memories> XML boundary prematurely, visually obscure instructions using Unicode bidirectional overrides, and execute stored prompt injection attacks against downstream LLM agents.

Alon Barad
Alon Barad
19 views•10 min read
•2 days ago•CVE-2026-77331
2.0

CVE-2026-77331: Race Condition and Session State Corruption in memtomem-stm

CVE-2026-77331 (GHSA-72jh-722p-rqr3) is a concurrency and session-state synchronization vulnerability in memtomem-stm, a short-term memory proxy gateway for AI agents. In versions 0.1.2 prior to 0.1.34, concurrent Model Context Protocol (MCP) Remote Procedure Call (RPC) failures or mid-flight task cancellations can initiate duplicate reconnect loops and permit dirty or cancelled transport sessions to be reused. This deficiency results in session-state integrity loss and local service degradation.

Amit Schendel
Amit Schendel
8 views•9 min read