fast-jwt
CVE-2026-107724 · GHSA-g3jj-5cmm-3hxx
Raw public JWK JSON accepted as an HMAC secret
High, 7.4 · Public source snapshot: November 12, 2026
Original portfolio report · Public advisory · CVE record
Shared credits and the scope of my investigation are documented below.
CVE-2026-107724 · GHSA-g3jj-5cmm-3hxx · fast-jwt · High
Public security research by Charles Vosburgh (
the-vibe-dev).
| Field | Value |
|---|---|
| Package | fast-jwt |
| Ecosystem | npm / Node.js |
| Severity | High |
| CVSS | 7.4 — CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N |
| Public affected version | 6.2.4 |
| Fixed | 6.3.0 |
| Weakness | CWE-347 — Improper Verification of Cryptographic Signature |
| Public PoC | Yes |
| Credit | Charles Vosburgh (the-vibe-dev) — reporter |
An application using fast-jwt 6.2.4 could configure verification with raw serialized asymmetric public JWK JSON and expect that material to verify RSA/ECDSA-style signatures. Instead, when the JSON string did not look like PEM, fast-jwt could classify it as an ordinary HMAC secret.
If the verifier accepted an HS* algorithm—either through a mixed algorithm list or through algorithm inference—an attacker who knew the same public JWK bytes could calculate a valid HMAC for attacker-selected JWT claims. The verifier would then accept the forged symmetric token even though the configured material was intended to be an asymmetric public key.
The attack does not recover or bypass the private RSA key. It succeeds because public asymmetric key material is reinterpreted as a shared symmetric secret.
Security invariant: The selected JWT algorithm family must be cryptographically bound to the semantic key type; asymmetric public material must never fall back to an HMAC byte string.
JWT verification has two linked inputs:
- the token's signature algorithm; and
- the semantic type of the verification key.
An RSA public key is safe to publish because it can verify RSA signatures without creating them. That security model collapses if the exact public bytes are reused as an HMAC secret: anyone who knows the public bytes can generate the MAC.
The vulnerable deployment prerequisites are specific:
- the application supplies raw serialized JWK/JWKS JSON as a string or buffer rather than converting it into a native asymmetric key object;
- the verifier accepts HS256 alongside an asymmetric family, or lets fast-jwt infer allowed algorithms; and
- the attacker knows the exact serialized public-key bytes used by the verifier, including property ordering/whitespace when a raw string is used.
An RS256-only verifier is not affected by the demonstrated HS256 forgery path.
Vulnerable key classification
In fast-jwt 6.2.4, algorithm detection distinguished recognizable PEM/certificate material from other strings. A non-empty string that was not recognized as PEM could fall into the generic HMAC-secret branch:
} else if (!publicKeyPemMatch && !trimmedKey.includes(publicKeyX509CertMatcher)) {
// Not a PEM, assume a plain secret
return hsAlgorithms
}
Raw RSA, EC, or OKP JWK JSON is not PEM and contains no X.509 header. The verifier therefore loses the semantic information that this string represents public asymmetric key material.
Once the key has been categorized as a secret, an HS256 token using the same serialized JSON bytes as its HMAC key is internally consistent from the verifier's mistaken point of view.
The public PoC generates an RSA key pair and exports only the public JWK. It then:
- serializes the public JWK to JSON;
- creates attacker-selected claims;
- signs those claims with HMAC-SHA-256 using the serialized public JWK string as the HMAC key;
- gives the same public JWK string to fast-jwt's verifier; and
- observes that the forged HS256 token is accepted in vulnerable 6.2.4 under the affected algorithm configurations.
A control verifier restricted to RS256 rejects the forged token.
That negative control is important: the vulnerability is not “RSA signatures can be forged.” It is algorithm/key-type confusion introduced when the verifier allows the symmetric family to be paired with data that semantically represents an asymmetric public key.
The key parser used representation shape as a proxy for key semantics. “Not recognizable PEM” became “plain symmetric secret,” even when the string was structured JSON whose kty explicitly identified RSA, EC, or OKP public-key material.
Cryptographic policy should fail closed when the key's semantic type and requested algorithm family disagree. Falling back from an unrecognized structured key to a generic secret is unsafe because it can convert intentionally public bytes into authentication material.
flowchart TD
A[Application configures verifier with raw serialized public JWK JSON]
B[HS algorithm is allowed or inferred]
C[fast-jwt 6.2.4 does not recognize JSON as asymmetric key material]
D[Verifier classifies the JSON string as an HMAC secret]
E[Attacker obtains the same public JWK bytes]
F[Attacker signs arbitrary claims with HS256 using those bytes]
G[Vulnerable verifier accepts forged token]
A --> B --> C --> D
E --> F --> G
D --> G
The PoC is public in GHSA-g3jj-5cmm-3hxx and is not duplicated as a separate artifact in this repository.
The published reproduction was run locally against the exact 6.2.4 package. The mixed-family and inference-enabled verifier cases accepted the forged claims. The RS256-only negative control rejected the HS256 token.
The fixed 6.3.0 upstream regression tests were also executed locally and passed. No production JWT service, account, key, or third-party endpoint was used.
The fixing commit is:
10f9591349199ed2ab9fa1748ce92cdca697f6cf
released in fast-jwt 6.3.0.
The fix recognizes JSON-looking key strings before the generic raw-secret fallback and rejects asymmetric structures when they are being treated as symmetric key material. The guarded structures include:
- a top-level JWK with
ktyofRSA,EC, orOKP; - a JWKS containing asymmetric keys; and
- a bare array containing asymmetric JWK values.
Symmetric JWKs using kty: "oct" and ordinary opaque HMAC secrets remain valid. An explicitly all-HS caller remains an intentional assertion that the supplied material is meant to be a symmetric secret; the fix targets mixed-family/inferred cases where asymmetric semantics would otherwise be silently lost.
The published GitHub advisory intentionally limits the affected version to:
6.2.4
and the fixed version to:
6.3.0
Public Git history traces the generic non-PEM-to-HMAC inference shape back to an older refactor (e3ff09f07b55414e1fdaad2b8f225aa94832b45a). That historical lineage does not expand the published affected range. Earlier releases were explicitly not assessed for the advisory and are not claimed affected here.
The exact npm artifacts and matching public tags for 6.2.4 and 6.3.0 were inspected.
Successful exploitation lets an attacker forge JWT claims accepted by the vulnerable verifier configuration without possessing the asymmetric private key.
The downstream effect depends on what the consuming application trusts from JWT claims. Common consequences can include impersonation, authorization bypass, or access to data/actions granted by forged roles or identities.
The public advisory rates the issue High, CVSS 7.4. Attack complexity is elevated because exploitation depends on a particular key representation and algorithm configuration, including knowledge of the exact serialized bytes used as the verifier key.
Upgrade to fast-jwt 6.3.0 or later.
Applications should also make their intended cryptographic model explicit:
- convert JWK/JWKS data into native asymmetric key objects where appropriate;
- restrict verifiers to the expected algorithm family rather than using mixed symmetric/asymmetric allowlists unless there is a compelling reason;
- reject keys whose semantic type conflicts with the selected JWT algorithm;
- avoid “unknown structured key => raw secret” fallback behavior.
Regression tests should cover RSA, EC, OKP, and oct JWK values as top-level JWKs, JWKS documents, arrays, PEM strings, and opaque secrets across both inferred and explicit algorithm lists.
| Date | Event |
|---|---|
| 2026-07-28 | GHSA-g3jj-5cmm-3hxx and public PoC published. |
| 2026-10-08 | CVE-2026-107724 published for this same advisory. |
| 2026 | fast-jwt 6.3.0 published with the fix. |
| 2026-08-26 | Exact affected/fixed package artifacts and public regression tests reviewed. |
GHSA-g3jj-5cmm-3hxx is a JWT algorithm/key-type confusion issue caused by losing asymmetric key semantics during string-based key detection. A public JWK that should only verify asymmetric signatures could be treated as an HMAC secret, allowing anyone who knew those public bytes to create a symmetric token that vulnerable configurations accepted.
Version 6.3.0 fixes the confusion by recognizing asymmetric JSON key structures before the generic secret fallback.
Broader lesson: Cryptographic key semantics must be explicit and fail closed. Public asymmetric material must never become a shared secret merely because its serialization format is unfamiliar to a parser.
- CVE-2026-107724
- https://github.com/nearform/fast-jwt/security/advisories/GHSA-g3jj-5cmm-3hxx
Charles Vosburgh (the-vibe-dev) — reporter.
Research was AI-assisted for source mapping, hypothesis generation, release comparison, and evidence organization. I performed the final validation, disclosure coordination, severity calibration, and publication review.
This write-up documents a publicly disclosed vulnerability for defensive research, remediation, regression testing, and authorized assessment. Test only with keys and applications you own or are explicitly authorized to assess.