CVE-2026-107724: Fast jwt Fast-jwt Treats Raw Public JWK Vulnerability

HIGH
Advisory Identifier: GHSA-g3jj-5cmm-3hxx
CVSS 7.4
CWE-347
Published
Advisory Summary

CVE-2026-107724 is a HIGH (CVSS 7.4) fast-jwt treats raw public jwk vulnerability (CWE-347: Improper Verification of Cryptographic Signature) affecting Fast jwt libraries in the npm ecosystem. The issue involves fast-jwt treats raw public jwk json as an hmac secret, enabling hs256 token forgery. Remediation is available by upgrading affected packages to version 6.3.0.

CVE-2026-107724 at a Glance

CVE Identifier CVE-2026-107724
GHSA Identifier GHSA-g3jj-5cmm-3hxx
Severity HIGH
CVSS v3.1 Base Score 7.4
CWE Classification CWE-347: Improper Verification of Cryptographic Signature
Affected Product Fast jwt
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-107724

To remediate this vulnerability, upgrade all affected Fast jwt dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

fast-jwt fixed: 6.3.0
npm install fast-jwt@6.3.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls fast-jwt

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-107724, inspect your project dependencies using npm:

npm ls fast-jwt

Analyze the terminal output to locate any version of Fast jwt in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.3.0), your application is affected.

Note: The npm ls fast-jwt command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-347: Improper Verification of Cryptographic Signature, where the product does not verify, or incorrectly verifies, the cryptographic signature for data. In Fast jwt, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary `fast-jwt` 6.2.4 silently classifies raw serialized public JWK JSON as an HMAC secret. If an application supplies public JWK JSON text as the verifier key and HS256 is explicitly allowed or automatically inferred, an attacker who knows the same public JSON text can use it as an HMAC key and create an arbitrary HS256 token that `fast-jwt` accepts as valid. This can result in authentication or authorization bypass through forged JWT claims. The PoC demonstrates the issue with a serialized RSA public JWK. The same non-PEM classification also applies to raw JWKS JSON text, although the attached standalone PoC focuses on the smallest JWK case. ### Details The verifier accepts a string or Buffer as key material. In `src/crypto.js`, `performDetectPublicKeyAlgorithms()` attempts to infer the permitted algorithm family from the supplied string. Strings matching supported PEM public-key formats are classified as asymmetric keys. Any other non-empty string is assumed to be an HMAC secret: ```js function performDetectPublicKeyAlgorithms(key) { const trimmedKey = key.trim() const publicKeyPemMatch = trimmedKey.match(publicKeyPemMatcher) if (trimmedKey.match(privateKeyPemMatcher)) { throw new TokenError( TokenError.codes.invalidKey, 'Private keys are not supported for verifying.' ) } else if ( publicKeyPemMatch && publicKeyPemMatch[1] === 'RSA' ) { return rsaAlgorithms } else if ( !publicKeyPemMatch && !trimmedKey.includes(publicKeyX509CertMatcher) ) { // Not a PEM, assume a plain secret return hsAlgorithms } // ... } A serialized RSA, EC, or OKP public JWK is valid JSON, but it is not PEM and does not contain a certificate header. It therefore reaches: return hsAlgorithms The HS256 verification path then uses the complete public JSON string as the HMAC key. Because JWK public-key material is public by design, an attacker can know the verifier's cryptographic key material. When that public material is reinterpreted as an HMAC secret, the attacker can calculate a valid HS256 signature over arbitrary claims. The vulnerable transition is: Public asymmetric JWK JSON | v Does not match PEM detection | v Classified as a plain secret | v HS256 permitted or inferred | v Attacker signs using public JSON bytes | v Forged token accepted The attached PoC demonstrates both relevant configurations: An explicit mixed-family allowlist: createVerifier({ key: rawJwk, algorithms: ['HS256', 'RS256'] }) No explicit algorithm allowlist: createVerifier({ key: rawJwk }) In the second configuration, fast-jwt detects the raw non-PEM string as symmetric key material and permits the HS algorithm family. An RS256-only verifier rejects the same forged token, providing a negative control: createVerifier({ key: rawJwk, algorithms: ['RS256'] }) The documentation describes asymmetric verifier keys as PEM-encoded public keys. The security issue is not that the raw JWK is successfully parsed as an asymmetric key. It is that ambiguous structured public-key text is silently reclassified as a symmetric secret rather than being rejected, and that this classification permits an attacker-controlled HS256 token. PoC Requirements: Node.js 20 or newer npm The attached submission ZIP Extract the attachment and run: cd poc npm install node poc.js The PoC performs the following steps: Generates a fresh RSA key pair locally. Exports only the public key as a JWK. Adds ordinary public JWK metadata such as kid, use, and alg. Serializes the public JWK as JSON. Uses the serialized public JWK text as an HS256 HMAC key. Creates a token containing attacker-selected administrative claims. Supplies the same raw public JSON string to the real fast-jwt verifier. Confirms acceptance with a mixed HS256/RS256 allowlist. Confirms acceptance when algorithm detection is left enabled. Confirms rejection with an RS256-only verifier. Expected output: mixed algorithms: forged token accepted inferred algorithms: forged token accepted RS256-only control: forged token rejected VULNERABLE: fast-jwt@6.2.4 accepted attacker-signed HS256 claims The accepted token contains: { "sub": "attacker", "role": "admin", "admin": true } The PoC operates entirely locally using a newly generated key pair. It does not contact any production service, identity provider, or third-party application. Impact An affected application may accept attacker-generated JWT claims as authentic. Depending on how verified claims are used, an attacker could potentially forge: user or subject identifiers; administrator roles; authorization scopes; permissions; tenant or organization identifiers; and application-specific authorization flags. This may result in authentication bypass, horizontal privilege escalation, vertical privilege escalation, or unauthorized access to protected application data. Exploitation requires all of the following: The application passes raw serialized public JWK or JWKS JSON text as the verifier key. HS256 is explicitly permitted or is inferred from the non-PEM string. The attacker knows the exact serialized bytes supplied to the verifier. Public JWK/JWKS material is normally available to relying parties and often exposed through public discovery endpoints. However, property ordering, whitespace, or other serialization differences may affect an attacker's ability to reproduce the exact HMAC key bytes. These integration and serialization requirements are represented by High attack complexity. Applications that supply a supported PEM public key and restrict verification to the expected asymmetric algorithm family are not affected by this PoC. Earlier package versions were not assessed as part of this report. Suggested remediation Structured public-key representations should be detected before an arbitrary non-PEM string is classified as symmetric key material. At minimum, JSON strings containing asymmetric JWK or JWKS structures should be rejected for HS* verification. Relevant asymmetric kty values include: RSA EC OKP Potential approaches include: Parse JSON-looking verifier strings before HMAC classification. Reject asymmetric JWK/JWKS structures for HS256, HS384, and HS512. Do not treat all non-PEM strings as symmetric secrets merely because PEM detection failed. Require explicit algorithm selection when the key format is ambiguous. Bind the permitted algorithm family to the semantic key type rather than the success or failure of PEM detection. Regression tests should cover: compact serialized JWK JSON; pretty-printed JWK JSON; raw JWKS JSON; RSA, EC, and OKP public keys; mixed symmetric/asymmetric algorithm allowlists; default algorithm detection; asymmetric-only algorithm controls; trailing whitespace and newline variants; and property-order and serialization variants. [fast-jwt-raw-jwk-hs256-submit.zip](https://github.com/user-attachments/files/30396435/fast-jwt-raw-jwk-hs256-submit.zip)

CVE-2026-107724 Affected Fast jwt Versions

1 component(s)
Fixed Versions:
6.3.0
Product / Package Ecosystem Affected Versions Fixed Version
fast-jwt
npm
≥ 6.2.4
< 6.3.0
All 1 versions
6.2.4
6.3.0

References

Frequently Asked Questions

What is CVE-2026-107724?
CVE-2026-107724 is a security vulnerability in Fast jwt involving fast-jwt treats raw public JWK JSON as an HMAC secret, enabling HS256 token forgery under CWE-347: Improper Verification of Cryptographic Signature.
Which Fast jwt versions are affected?
Affected versions include releases prior to 6.3.0 across affected packages: fast-jwt.
What version fixes CVE-2026-107724?
Upgrading to 6.3.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is fast-jwt affected?
Yes, fast-jwt is affected in releases prior to 6.3.0. Upgrade your dependency to 6.3.0 or later.
What is the CVSS score of CVE-2026-107724?
CVE-2026-107724 has a CVSS v3.1 base score of 7.4 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-107724?
CVE-2026-107724 is classified under CWE-347: Improper Verification of Cryptographic Signature (The product does not verify, or incorrectly verifies, the cryptographic signature for data.).
How can I check npm dependencies for CVE-2026-107724?
Run the dependency tree command: 'npm ls fast-jwt'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-g3jj-5cmm-3hxx",
  "modified" : "2026-10-08T22:01:53Z",
  "published" : "2026-10-08T22:01:53Z",
  "aliases" : [ "CVE-2026-107724" ],
  "summary" : "fast-jwt treats raw public JWK JSON as an HMAC secret, enabling HS256 token forgery",
  "details" : "### Summary\n\n`fast-jwt` 6.2.4 silently classifies raw serialized public JWK JSON\nas an HMAC secret.\n\nIf an application supplies public JWK JSON text as the verifier key and\nHS256 is explicitly allowed or automatically inferred, an attacker who\nknows the same public JSON text can use it as an HMAC key and create an\narbitrary HS256 token that `fast-jwt` accepts as valid.\n\nThis can result in authentication or authorization bypass through forged\nJWT claims.\n\nThe PoC demonstrates the issue with a serialized RSA public JWK. The same\nnon-PEM classification also applies to raw JWKS JSON text, although the\nattached standalone PoC focuses on the smallest JWK case.\n\n### Details\n\nThe verifier accepts a string or Buffer as key material. In\n`src/crypto.js`, `performDetectPublicKeyAlgorithms()` attempts to infer\nthe permitted algorithm family from the supplied string.\n\nStrings matching supported PEM public-key formats are classified as\nasymmetric keys. Any other non-empty string is assumed to be an HMAC\nsecret:\n\n```js\nfunction performDetectPublicKeyAlgorithms(key) {\n  const trimmedKey = key.trim()\n  const publicKeyPemMatch = trimmedKey.match(publicKeyPemMatcher)\n\n  if (trimmedKey.match(privateKeyPemMatcher)) {\n    throw new TokenError(\n      TokenError.codes.invalidKey,\n      'Private keys are not supported for verifying.'\n    )\n  } else if (\n    publicKeyPemMatch &&\n    publicKeyPemMatch[1] === 'RSA'\n  ) {\n    return rsaAlgorithms\n  } else if (\n    !publicKeyPemMatch &&\n    !trimmedKey.includes(publicKeyX509CertMatcher)\n  ) {\n    // Not a PEM, assume a plain secret\n    return hsAlgorithms\n  }\n\n  // ...\n}\n\nA serialized RSA, EC, or OKP public JWK is valid JSON, but it is not PEM\nand does not contain a certificate header. It therefore reaches:\n\nreturn hsAlgorithms\n\nThe HS256 verification path then uses the complete public JSON string as\nthe HMAC key.\n\nBecause JWK public-key material is public by design, an attacker can know\nthe verifier's cryptographic key material. When that public material is\nreinterpreted as an HMAC secret, the attacker can calculate a valid\nHS256 signature over arbitrary claims.\n\nThe vulnerable transition is:\n\nPublic asymmetric JWK JSON\n        |\n        v\nDoes not match PEM detection\n        |\n        v\nClassified as a plain secret\n        |\n        v\nHS256 permitted or inferred\n        |\n        v\nAttacker signs using public JSON bytes\n        |\n        v\nForged token accepted\n\nThe attached PoC demonstrates both relevant configurations:\n\nAn explicit mixed-family allowlist:\ncreateVerifier({\n  key: rawJwk,\n  algorithms: ['HS256', 'RS256']\n})\nNo explicit algorithm allowlist:\ncreateVerifier({\n  key: rawJwk\n})\n\nIn the second configuration, fast-jwt detects the raw non-PEM string as\nsymmetric key material and permits the HS algorithm family.\n\nAn RS256-only verifier rejects the same forged token, providing a\nnegative control:\n\ncreateVerifier({\n  key: rawJwk,\n  algorithms: ['RS256']\n})\n\nThe documentation describes asymmetric verifier keys as PEM-encoded\npublic keys. The security issue is not that the raw JWK is successfully\nparsed as an asymmetric key. It is that ambiguous structured public-key\ntext is silently reclassified as a symmetric secret rather than being\nrejected, and that this classification permits an attacker-controlled\nHS256 token.\n\nPoC\n\nRequirements:\n\nNode.js 20 or newer\nnpm\nThe attached submission ZIP\n\nExtract the attachment and run:\n\ncd poc\nnpm install\nnode poc.js\n\nThe PoC performs the following steps:\n\nGenerates a fresh RSA key pair locally.\nExports only the public key as a JWK.\nAdds ordinary public JWK metadata such as kid, use, and alg.\nSerializes the public JWK as JSON.\nUses the serialized public JWK text as an HS256 HMAC key.\nCreates a token containing attacker-selected administrative claims.\nSupplies the same raw public JSON string to the real\nfast-jwt verifier.\nConfirms acceptance with a mixed HS256/RS256 allowlist.\nConfirms acceptance when algorithm detection is left enabled.\nConfirms rejection with an RS256-only verifier.\n\nExpected output:\n\nmixed algorithms: forged token accepted\ninferred algorithms: forged token accepted\nRS256-only control: forged token rejected\nVULNERABLE: fast-jwt@6.2.4 accepted attacker-signed HS256 claims\n\nThe accepted token contains:\n\n{\n  \"sub\": \"attacker\",\n  \"role\": \"admin\",\n  \"admin\": true\n}\n\nThe PoC operates entirely locally using a newly generated key pair. It\ndoes not contact any production service, identity provider, or\nthird-party application.\n\nImpact\n\nAn affected application may accept attacker-generated JWT claims as\nauthentic.\n\nDepending on how verified claims are used, an attacker could potentially\nforge:\n\nuser or subject identifiers;\nadministrator roles;\nauthorization scopes;\npermissions;\ntenant or organization identifiers; and\napplication-specific authorization flags.\n\nThis may result in authentication bypass, horizontal privilege\nescalation, vertical privilege escalation, or unauthorized access to\nprotected application data.\n\nExploitation requires all of the following:\n\nThe application passes raw serialized public JWK or JWKS JSON text as\nthe verifier key.\nHS256 is explicitly permitted or is inferred from the non-PEM string.\nThe attacker knows the exact serialized bytes supplied to the\nverifier.\n\nPublic JWK/JWKS material is normally available to relying parties and\noften exposed through public discovery endpoints. However, property\nordering, whitespace, or other serialization differences may affect an\nattacker's ability to reproduce the exact HMAC key bytes.\n\nThese integration and serialization requirements are represented by\nHigh attack complexity.\n\nApplications that supply a supported PEM public key and restrict\nverification to the expected asymmetric algorithm family are not\naffected by this PoC.\n\nEarlier package versions were not assessed as part of this report.\n\nSuggested remediation\n\nStructured public-key representations should be detected before an\narbitrary non-PEM string is classified as symmetric key material.\n\nAt minimum, JSON strings containing asymmetric JWK or JWKS structures\nshould be rejected for HS* verification. Relevant asymmetric kty\nvalues include:\n\nRSA\nEC\nOKP\n\nPotential approaches include:\n\nParse JSON-looking verifier strings before HMAC classification.\nReject asymmetric JWK/JWKS structures for HS256, HS384, and HS512.\nDo not treat all non-PEM strings as symmetric secrets merely because\nPEM detection failed.\nRequire explicit algorithm selection when the key format is\nambiguous.\nBind the permitted algorithm family to the semantic key type rather\nthan the success or failure of PEM detection.\n\nRegression tests should cover:\n\ncompact serialized JWK JSON;\npretty-printed JWK JSON;\nraw JWKS JSON;\nRSA, EC, and OKP public keys;\nmixed symmetric/asymmetric algorithm allowlists;\ndefault algorithm detection;\nasymmetric-only algorithm controls;\ntrailing whitespace and newline variants; and\nproperty-order and serialization variants.\n[fast-jwt-raw-jwk-hs256-submit.zip](https://github.com/user-attachments/files/30396435/fast-jwt-raw-jwk-hs256-submit.zip)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "fast-jwt"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "6.2.4"
      }, {
        "fixed" : "6.3.0"
      } ]
    } ],
    "versions" : [ "6.2.4" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nearform/fast-jwt/security/advisories/GHSA-g3jj-5cmm-3hxx"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nearform/fast-jwt/pull/636"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nearform/fast-jwt/commit/10f9591349199ed2ab9fa1748ce92cdca697f6cf"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nearform/fast-jwt"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nearform/fast-jwt/releases/tag/v6.3.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-347" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-08T22:01:53Z",
    "nvd_published_at" : null
  }
}