CVE-2026-107722: fast-jwt: Incomplete patch of CVE-2026-34950: Non-whitespace key-prefix re-enables RSA→HS256 algorithm confusion
The fix for CVE-2026-34950 (CVSS 9.1, released in v6.2.0) is incomplete. It adds key.trim() to the PEM-detection path in src/crypto.js, but String.prototype.trim() only strips characters classified as whitespace by the ECMAScript specification. The subsequent ^-anchored regex (/^-----BEGIN(?: (RSA))? PUBLIC KEY-----/) still requires the PEM header at position 0 — so any non-whitespace leading byte (control chars, zero-width unicode, # comments, HTTP-style headers, PGP wrappers) bypasses detection and falls through to the HMAC verification path, using the RSA public key as the HMAC shared secret. Net result: the exact same RSA→HS256 algorithm-confusion attack the original CVE addressed is fully re-enabled with a slightly different leading byte.
Attack prerequisites are identical to CVE-2026-34950: attacker knows the target’s public RSA key (which is public by definition), and the target loads that key from a source whose content may have a non-whitespace prefix (DB column with corrupted encoding, YAML config with inline comment, copy-paste from formatted document, etc.).
Verified on fast-jwt@6.2.2 (latest as of 2026-04-23) with a 10-line PoC.
References
- github.com/advisories/GHSA-ww5h-9m49-7xx4
- github.com/nearform/fast-jwt/commit/d96bbc6c5336055a6dbfa318fdbab01197264cfa
- github.com/nearform/fast-jwt/pull/632
- github.com/nearform/fast-jwt/releases/tag/v6.3.0
- github.com/nearform/fast-jwt/security/advisories/GHSA-ww5h-9m49-7xx4
- nvd.nist.gov/vuln/detail/CVE-2026-107722
Code Behaviors & Features
Detect and mitigate CVE-2026-107722 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Dependency Scanning using SBOM also detects vulnerabilities from proprietary advisories that this site does not include. Learn more about Dependency Scanning using SBOM →