
Key points
- CVE-2026-107722 affects fast-jwt versions 6.2.0 through 6.2.4 due to an incomplete fix for a previous algorithm confusion bug.
- The vulnerability allows attackers to use a known RSA public key as an HMAC secret, enabling authentication bypass.
- A patched version, 6.3.0, has been released to address the issue.
The popular JSON Web Token (JWT) library fast-jwt contains a critical vulnerability in its recent 6.2.x releases that allows attackers to forge authentication tokens. This flaw, tracked as CVE-2026-107722, stems from an incomplete patch for a previous security issue, effectively re-enabling a method for token forgery that was previously addressed.
According to the GitHub advisory GHSA-ww5h-9m49-7xx4, the vulnerability arises because the fix for CVE-2026-34950, released in version 6.2.0, only partially resolved the underlying problem. The original patch added a trimming function to the key input to remove whitespace before checking for a PEM header. However, the subsequent regular expression used to detect the public key format remains anchored to the start of the string. Consequently, any non-whitespace characters placed before the PEM header—such as control characters, zero-width unicode symbols, comments, or wrapper text—prevent the system from recognising the key as a public key.
When the PEM detection fails, the library falls back to treating the input as an HMAC secret. This allows an attacker who possesses the target’s public RSA key to sign arbitrary HS256 claims using that public material. The result is a successful authentication or authorisation bypass. The National Vulnerability Database (NVD) rates this vulnerability as Critical with a CVSS score of 9.8.
Context and Technical Background
The flaw is located in the `performDetectPublicKeyAlgorithms` function within the `src/crypto.js` file of the fast-jwt library. While the `String.prototype.trim()` method successfully removes standard whitespace characters, it does not strip other non-whitespace leading bytes. Because the `publicKeyPemMatcher` regular expression requires the PEM header to begin at position 0, any preceding non-whitespace character causes the match to fail.
This failure triggers the HMAC verification path, where the RSA public key is incorrectly used as the shared secret. The attack prerequisites are identical to the original CVE-2026-34950: the attacker must know the target’s public RSA key, which is inherently public, and the target must load that key from a source that might include a non-whitespace prefix. Examples of such sources include database columns with corrupted encoding, YAML configuration files with inline comments, or keys copied from formatted documents.
Who Is Affected
The vulnerability affects all versions of fast-jwt from 6.2.0 up to and including 6.2.4. According to the GitHub advisory, version 6.3.0 contains the fix. Security teams should verify their current installations, particularly if they have recently updated from versions prior to 6.2.0 in response to the earlier CVE-2026-34950 disclosure.
Our take on the response
The release of version 6.3.0 addresses the incomplete patching of the algorithm confusion vulnerability. Security operations teams should prioritise updating their dependencies to this version to eliminate the risk of token forgery via public key misuse. Given the ease of exploitation and the critical severity, immediate remediation is advised for any systems relying on fast-jwt for authentication.
What to do and how to stay safe: fast-jwt
- Audit your dependency trees to identify any usage of fast-jwt versions 6.2.0 through 6.2.4.
- Upgrade to fast-jwt version 6.3.0 or later as soon as possible to apply the confirmed fix.
- Review your JWT configuration to ensure that asymmetric-only algorithm allowlists are enforced, which prevents the HMAC fallback path.
- Monitor logs for unusual authentication patterns or token signing anomalies that might indicate exploitation attempts.
Step-by-step guide: Out-of-Band Patches: How Emergency Updates Prevent Downtime
General security guidance from the Breach Observer newsroom. It is not confirmed advice from the organisations named in this story.
Frequently asked questions
What is CVE-2026-107722?
It is a critical vulnerability in fast-jwt versions 6.2.0 to 6.2.4 that allows attackers to forge JWTs by misclassifying RSA public keys as HMAC secrets due to non-whitespace characters in the key input.
How can an attacker exploit this vulnerability?
An attacker can exploit this by using a known RSA public key with a non-whitespace prefix to sign HS256 claims, bypassing authentication if the system allows HMAC verification.
Is there a fix available?
Yes, the vulnerability is fixed in fast-jwt version 6.3.0. Users should upgrade to this version to mitigate the risk.