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·27 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

•13 minutes ago•CVE-2026-28385
5.0

CVE-2026-28385: Server-Side Request Forgery in Canonical LXD Image Import

CVE-2026-28385 (GHSA-3gq2-x4qg-p4g6) is a Server-Side Request Forgery (SSRF) vulnerability in Canonical LXD versions 4.12 through 6.9. An authenticated user possessing the can_create_images entitlement can force the LXD daemon to execute arbitrary outbound HTTP and HTTPS requests via the /1.0/images API endpoint. Due to the absence of egress destination validation, an attacker can probe host loopback services, RFC 1918 private network segments, and cloud Instance Metadata Services (IMDS) from the network position of the privileged LXD daemon.

Amit Schendel
Amit Schendel
0 views•9 min read
•about 1 hour ago•GHSA-9J25-MM2H-2F76
9.9

CVE-2026-48750: Arbitrary File Write on Host via exec-output Symlink in Canonical LXD and Incus

Canonical LXD and LXC Incus contain an arbitrary file write vulnerability (CWE-73 / CWE-59) in the `/1.0/instances/<name>/exec` REST API endpoint. When an instance is unpacked from an image archive, top-level symbolic links are extracted directly onto the host filesystem within the instance storage directory. If a crafted image includes a symbolic link named `exec-output` pointing to an arbitrary host path, invoking the execution endpoint with `record-output: true` causes the privileged host daemon to follow the symlink and write command output files directly to the target host directory. An authenticated attacker with permissions to import images and execute commands can exploit this flaw to write controlled content to sensitive host directories such as `/etc/cron.d`, resulting in arbitrary code execution on the host as `root`.

Alon Barad
Alon Barad
4 views•12 min read
•about 2 hours ago•GHSA-VGHH-5RFX-XHQ8
9.9

CVE-2026-48749: Arbitrary Host File Read and Write via Malicious Image Symlink in Canonical LXD and Incus

CVE-2026-48749 (tracked as GHSA-vghh-5rfx-xhq8 for LXD and GHSA-2q3f-q5pq-g8wv for Incus) is a critical container escape vulnerability in the Canonical LXD and Linux Containers Incus system container managers. By importing a specially crafted container image archive containing duplicate tar member headers, an authenticated attacker can replace the instance rootfs directory with a symbolic link pointing to the underlying host root filesystem. When performing file operations on a stopped container, the privileged forkfile helper binary resolves the symbolic link without confinement and chroots directly into the host filesystem, granting arbitrary root-level file read and write access.

Amit Schendel
Amit Schendel
3 views•9 min read
•about 3 hours ago•GHSA-FMC8-P6Q7-75CC
9.9

GHSA-fmc8-p6q7-75cc: Argument Injection in Canonical LXD Backup Compression Leads to Host Root Code Execution

GHSA-fmc8-p6q7-75cc (associated with CVE-2026-48755) is a critical argument injection vulnerability in Canonical LXD (github.com/canonical/lxd). The vulnerability occurs during instance and storage volume backup operations when processing the user-supplied compression_algorithm configuration parameter. While LXD validates the primary executable token against an allowlist of supported compression binaries, it fails to sanitize or restrict subsequent tokens parsed via shellquote.Split. These additional arguments are passed directly to exec.Command. An authenticated attacker with privileges to trigger backups can inject command-line flags for utilities like zstd to read staged files from a container filesystem and write them to arbitrary paths on the underlying host filesystem, such as /etc/cron.d/, achieving root-level arbitrary code execution on the host.

Amit Schendel
Amit Schendel
6 views•10 min read
•about 4 hours ago•GHSA-PJFF-C2WC-F6JM
9.9

CVE-2026-48769: Arbitrary File Write and Remote Code Execution via Trusted Image Hash in Canonical LXD and Linux Containers Incus

A critical path traversal vulnerability caused by improper input validation (CWE-20) exists in the direct image download handler of Canonical LXD and Linux Containers Incus. When an authenticated user requests an image import using the URL source type, the daemon reads the image fingerprint from an untrusted HTTP response header (`Incus-Image-Hash` or `LXD-Image-Hash`) without validating that it conforms to a SHA-256 format. This unvalidated string is concatenated directly into a filesystem path via `filepath.Join` prior to file creation and cryptographic verification, allowing directory traversal sequences to write arbitrary files on the host filesystem as root.

Alon Barad
Alon Barad
7 views•10 min read
•about 8 hours ago•CVE-2026-9639
6.5

CVE-2026-9639: Authenticated Denial of Service via Nil-Pointer Dereference in Canonical LXD Custom Volume Backup Import

CVE-2026-9639 (GHSA-j93m-3j9p-m5m8) is a null pointer dereference vulnerability in Canonical LXD affecting versions 5.0.0 through 5.21.4 and 6.0 through 6.8. The flaw resides in the (*lxdBackend).CreateCustomVolumeFromBackup method within lxd/storage/backend_lxd.go. An authenticated attacker with the can_create_storage_volumes permission can upload a crafted custom volume backup tarball that omits the expires_at field on a snapshot entry, triggering an unhandled SIGSEGV panic and terminating the LXD daemon.

Amit Schendel
Amit Schendel
7 views•9 min read