JSON Web Tokens

A JWT is a signed (JWS) or encrypted (JWE) set of JSON claims used as a bearer credential; the vulnerability class is the gap between a token the server should trust and one it does trust — almost always a verification flaw that lets an attacker forge or misuse tokens.

What it is

A JWS JWT is three base64url segments — header.payload.signature — joined by dots. The header (JOSE header) names the signing algorithm in alg and may carry key hints (kid, jwk, jku, x5c, x5u); the payload holds claims (iss, sub, aud, exp, nbf, iat, jti, plus app claims); the signature is HMAC (HS, symmetric) or a public-key signature (RS/PS/ES/EdDSA). The payload is encoded, not encrypted — anything secret in it is readable by anyone holding the token. (“JWT” in practice means JWS; JWE encrypts the contents.)

The trust boundary that breaks: the header is attacker-controlled and is read before the signature is checked, because the verifier needs it to know how to check the signature. Every major JWT bug is a server trusting that pre-verification input — the algorithm, the key reference, or a claim — more than it should. As PortSwigger puts it, the flaws almost always mean the signature is not verified properly, or the key that backs it is not actually secret. Curity’s framing: JWT security comes from implementation and validation, not the format.

Why it matters

JWTs gate authentication, authorization and SSO across APIs, OAuth2/OIDC and microservices. A token-verification bug is usually a complete authentication bypass: forge a token with arbitrary sub/role/isAdmin and you impersonate any user or escalate to admin — often pre-auth, often with only public information (the public key).

Impact ladder:

  • Tamper claims when the signature is unchecked → privilege escalation / user impersonation (XBEN-027, Newspack).
  • Forge any token via algorithm confusion, none, empty key, header injection or a cracked/leaked secret → full account takeover with no victim interaction.
  • Pivot further: forged admin → SSTI/RCE (Intigriti CTF, TryHackMe Hammer), or into ICS/SCADA and IoT root (CIRCUTOR PowerStudio, Cudy routers).
  • Cross-tenant / cross-service: missing iss/aud checks accept tokens meant for another realm or service (Apache Camel, Argo CD).

Severity drivers: whether HMAC and asymmetric algorithms share a verifier, whether the secret is strong and secret, whether key references in the header are trusted, whether iss/aud/exp are asserted, and how fast a bad token can be revoked. 2026 saw this class land as maximum-severity CVEs across Keycloak, pac4j, Parse Server, PAN-OS, Hono and the Python JOSE ecosystem.

How it works (mechanism and variants)

Each variant links its detailed page.

  • JWT Algorithm Confusion — force the verifier onto a different algorithm than intended, classically RS256→HS256 with the server’s public key as the HMAC secret. Root cause: alg-driven dispatch plus a raw key shared across algorithm families. Still shipping: Hono (CVE-2026-22817), PAN-OS (CVE-2026-0265), Keycloak (CVE-2026-11800), Parse Server (CVE-2026-27804), fast-jwt (CVE-2026-107722).
  • JWT None Algorithm — accept an unsecured token (alg:none, empty signature) or otherwise skip the signature check (unknown-alg empty signature, null signature, decode() vs verify(), plain JWT inside JWE). CIRCUTOR SCADA (CVE-2026-120387), Cudy (CVE-2026-75491), pac4j (CVE-2026-29000), HarbourJwt (CVE-2026-23993).
  • JWT Header Injection — abuse jwk/jku/x5c/x5u/kid so the verifier trusts an attacker key, or turn kid lookup into path-traversal / SQLi / SSRF. Authlib (CVE-2026-27962), Dart jose (CVE-2026-34240), PortSwigger labs.
  • JWT Empty Key Forgery — a zero-length HMAC key makes the signature a public, reproducible function. Authlib (CVE-2026-114616), ruby-jwt (USN-9059-1), python-jose (CVE-2026-120459), PyJWT PyJWK (CVE-2026-102266), libjwt, fast-jwt (CVE-2026-107720).
  • JWT Secret Cracking — recover a weak HS* secret offline (hashcat -m 16500), or find a hardcoded/default/leaked one (Tensei, Simple Admin Core, JS-bundle fallback, Trint client-side generation).
  • JWT Claim Validation Failures — valid signature but wrong/expired/replayed token: missing aud (Argo CD), missing iss (Apache Camel), clock-skew and never-expiring tokens (@fastify/jwt CVE-2026-107275), jti list bypass (joserfc), non-canonical claim names (cap CVE-2026-19194), crit ignored (PyJWT CVE-2026-32597).
  • JWT Token Lifecycle and Revocation — stateless tokens outlive logout/reset; storage, theft, expiry, refresh rotation and revocation strategy set the blast radius.
  • Python JWT Library Vulnerabilities — the PyJWT/Authlib/joserfc/python-jose/jwcrypto run of public-key-as-HMAC, empty-HMAC and Python type-quirk bugs (python topic — linked, not duplicated here).

Where to find it

  • Carriers: Authorization: Bearer eyJ..., session cookies, access_token/id_token in OAuth/OIDC flows, WebSocket connectionParams, GraphQL auth directives, custom headers. Regex [= ]eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9._-]*.
  • Key endpoints: /.well-known/jwks.json, /jwks.json, OIDC jwks_uri, embedded in mobile/JS bundles and source maps.
  • JWKS hygiene: a public JWKS must hold only public parameters. d/p/q/dp/dq/qi on an RSA key (or d on EC) means a published private key; kty: "oct" with k means a published HMAC secret; also flag missing or duplicate kid, RSA < 2048 bits, and alg/kty or use/key_ops mismatches (JWKS and kid).
  • Hot spots: custom verification code; libraries configured with a mixed HS+RS allow-list; kid-driven key lookups; JWE/nested tokens; OAuth adapters (Parse Server), SSO bridges (Jitsi, Trint), IoT/SCADA auth plugins, GraphQL auth (@neo4j/graphql CVE-2026-92683), WordPress JWT plugins, edge/serverless frameworks (Hono on Workers/Deno/Bun).
  • Frameworks/libs: PyJWT, Authlib, python-jose, joserfc, jwcrypto (Python); jsonwebtoken, @fastify/jwt, jose, Hono (Node); ruby-jwt; golang-jwt; libjwt/cjwt (C); lua-resty-jwt; Spring Security, JWTKit (Swift).

How to test

Methodology (jwt_tool playbook / OWASP WSTG / PortSwigger), roughly in order:

  1. Find and replay. Locate the token via an intercepting proxy; replay it to confirm a stable, authorized response (a profile endpoint works well).
  2. Is it required / checked / persistent? Remove it; truncate the signature. If a truncated signature is still accepted, the signature is not verified — tamper the payload directly.
  3. Unsigned / skip-verify. Try alg:none and case/encoding variants, unknown alg with empty signature, zero-length signature with the original alg.
  4. Algorithm confusion. Fetch or derive the public key (JWKS, OIDC, TLS cert, or rsa_sign2n/sig2n from 1–2 tokens); re-sign with HS* using multiple key encodings (PEM ±trailing newline, PKCS#1/SPKI, raw JWK, DER).
    • For a JWKS-published key: JWK → PEM → base64 of the whole PEM as the symmetric k; keep kid, switch alg to HS256 (juangrate).
  5. Empty key. Re-sign HS* with an empty secret "".
  6. Header injection. Embed a jwk; point jku/x5u at a collaborator host (watch for SSRF, test allow-list bypasses); set kid to ../../../dev/null (empty secret), SQL metacharacters, command/SSRF payloads.
  7. Secret cracking. Offline hashcat/jwt_tool/CookieMonster against captured tokens; search bundles/config for secrets.
  8. Claims. Edit aud/iss; send expired tokens (measure grace); set claims to null/booleans/arrays; cross-service replay; unknown crit.
  9. Edge cases. Nested JWT (cty: JWT) where only the outer token is validated; claim type confusion ("role": ["admin"] vs "admin") and fullwidth-Unicode normalization mismatches between filter and consumer (robinx0).

Checklist (ship-gate):

  • Signature verified on every request (verify, not decode); truncated/empty signatures rejected.
  • none and unknown algorithms rejected; algorithm allow-list pinned from config.
  • No verifier mixes HMAC with asymmetric algorithms on one key.
  • Zero-length and sub-256-bit HMAC keys rejected.
  • Header key references (jwk/jku/x5c/x5u) ignored or strictly allow-listed; kid mapped via allow-list, never a path/SQL/shell.
  • iss and aud asserted; exp/nbf checked with tight skew; exp required.
  • Short access-token lifetime; refresh rotation; revocation on reset/logout.
  • No secrets in client bundles; secrets ≥256-bit from a CSPRNG; asymmetric signing preferred.
  • Library version postdates the relevant CVEs; negative tests prove each fix.

Exploitation and escalation

  • Claim tampering → Broken Access Control / privilege escalation when the signature is unchecked.
  • Forged admin token → chain to Server-Side Template Injection/RCE, or to SSRF via jku.
  • kid injection → path traversal, SQLi, command injection, SSRF key fetch.
  • Stolen token replay / cross-service relay → account takeover across services sharing an issuer (see JWT Claim Validation Failures, JWT Token Lifecycle and Revocation).
  • Nested JWE → inner unsigned JWT accepted (pac4j); invalid-curve attacks on JWE/ECDH (RFC 7516 errata; “Off the Curve” CTF).
  • Pre-auth DoS through the verifier: header values that drive cost (the PBES2 p2c iteration count fed unbounded to hash_pbkdf2() in web-token jwt-framework, CVE-2026-134461) or malformed signatures that make verify() throw instead of return false (lcobucci/jwt ECDSA, see below) need no key and no valid token (web-token, lcobucci). An exception path can also skip logic that only runs on a false result: failed-attempt counters, rate limiting, audit logging.

Bypassing defenses

  • none-filter bypass: mixed case (None, NONE), unexpected encodings; filters that string-match none.
  • Public-key-guard bypass (algorithm confusion): a library sniffs “is this a public key?” and the denylist misses an encoding — leading non-whitespace byte (fast-jwt), OpenSSH/DER (Authlib, joserfc), raw JWK JSON container (PyJWT). Content-sniffing is not a fix.
  • jku/x5u allow-list bypass: startsWith/contains instead of parsed scheme+host+port equality; open redirect on the trusted host; attacker-writable content on the trusted origin (see URL Parser Differentials).
  • Claim-check bypass: empty-string/array-coerced aud (golang-jwt), partial iss match (PyJWT CVE-2024-53861), jti list membership (joserfc), JSON null/boolean claims (jwcrypto), non-canonical claim names (cap), silently ignored crit.
  • Expiry bypass: default multi-minute clock skew; malformed time spans producing never-expiring tokens (@fastify/jwt).
  • Incomplete-patch bypass: fast-jwt CVE-2026-107722 (re-enabled CVE-2026-34950), Authlib CVE-2026-114615 — re-test after a vendor “fix”.

Real-world cases

  • CIRCUTOR PowerStudio SCADA WAVE (CVE-2026-120387) — alg:none identity forgery → RCE chain in ICS/SCADA. JWT None Algorithm
  • Cudy TR3000/AX3000 (CVE-2026-75491) — alg none + trusted client cert → root command execution over MQTT. JWT None Algorithm
  • PAN-OS / Panorama (CVE-2026-0265) — algorithm confusion in pan_auth_verify; pre-auth login as any user when CAS attached. JWT Algorithm Confusion
  • Keycloak (CVE-2026-11800) — algorithm confusion in the JWT Authorization Grant; forge assertions for any federated user. JWT Algorithm Confusion
  • pac4j-jwt (CVE-2026-29000, max severity) — unsigned PlainJWT inside RSA JWE accepted; impersonation. JWT None Algorithm
  • Parse Server (CVE-2026-27804, CVSS 9.3) — OAuth adapters passed header alg into jwt.verify; none or HS256-with-Google-key ATO. JWT Algorithm Confusion
  • Hono (CVE-2026-22817) — RS256→HS256 on edge runtimes. JWT Algorithm Confusion
  • Authlib (CVE-2026-27962 jwk-injection; CVE-2026-114616 empty HMAC; CVE-2026-114615 confusion-fix bypass) — three distinct 2026 verification bypasses. JWT Header Injection / JWT Empty Key Forgery
  • Apache Camel KeycloakSecurityPolicy (CVE-2026-23552) — unverified iss → cross-realm acceptance. JWT Claim Validation Failures
  • Argo CD (IBB, critical) — unverified aud on OIDC tokens. JWT Claim Validation Failures
  • @neo4j/graphql (CVE-2026-92683, and connectionParams bypass) — multi-condition @authentication filter bypass; subscription auth via unverified connectionParams.jwt.
  • Jitsi Meet (GHSA-45ff-37jm-xjfx) — public key as HMAC secret into protected rooms. JWT Algorithm Confusion
  • JS-bundle fallback secret (siteguarding) — production HS256 key shipped in client code → auth bypass + cross-user write. JWT Secret Cracking
  • Tensei (CVE-2026-129552) / Simple Admin Core — hardcoded/default JWT secret → forged super-admin; Tensei ≤ 0.11.5 falls back to auth-secret-key when JWT_SECRET is unset (CWE-1394) (VulnCheck). JWT Secret Cracking
  • BISHENG < 3.0.0 (CVE-2026-130840, CVSS 9.3, CWE-321) — hard-coded default jwt_secret: offline HS256 token for user_id 1 with admin role, sent as access_token_cookie. JWT Secret Cracking (VulnCheck)
  • Intel/CBSE AI Student Community — HS256 secret intel cracked with rockyou; forged token + sequential /dashboard/{ID} brute force + email enumeration → ATO; fixed by rotation, session invalidation and authz. JWT Secret Cracking (Intel Inside)
  • API-gateway RS256→HS256 ($4,500) — unpinned verification at a central gateway let a guest forge an admin token. JWT Algorithm Confusion (Medium)
  • @fastify/jwt (CVE-2026-107275) — malformed time spans → never-expiring tokens. JWT Claim Validation Failures
  • python-jwt + jwcrypto (CVE-2022-39227) — parser-inconsistency claim forgery. Python JWT Library Vulnerabilities
  • HarbourJwt (CVE-2026-23993) — any unknown alg → empty-signature bypass; found by LLM-assisted triage. JWT None Algorithm
  • Better Auth Expo (GHSA-4wq4-2ppv-q3hg) — signing oracle: a public endpoint signed attacker state, accepted elsewhere → zero-click ATO.
  • jsonwebtoken (CVE-2022-23529) — RCE on crafted token given a separate secret-management flaw; later downgraded (caller-side risk).
  • Nextcloud Whiteboard (SSRF → DevTools) — SSRF leaking JWT auth tokens; token theft as impact. JWT Token Lifecycle and Revocation
  • HashiCorp cap/jwt ≤ 0.13.0 (CVE-2026-19194, HCSEC-2026-60) — non-canonical claim names bypass Expected.Issuer/Expected.Subject; needs a trusted-but-compromised IdP; fixed 0.14.0. JWT Claim Validation Failures (HCSEC-2026-60)
  • web-token jwt-framework / jwt-library (CVE-2026-134461) — PBES2AESKW::unwrapKey() passed attacker p2c to hash_pbkdf2() with no upper bound; one JWE with a huge iteration count exhausts CPU unauthenticated; fixed 3.4.10, 4.0.7, 4.1.7 (GHSA-gxh8-83xg-w4p6)
  • lcobucci/jwt 5.6.1 / 6.0.x (GHSA-g3gx-p6xp-9gxq) — MultibyteStringConverter::toAsn1() writes DER lengths with unpadded dechex(); an ES256/384/512 signature whose R or S has ≥17 leading zero bytes (e.g. R = S = 1) yields odd-length hex, hex2bin() fails, and verify() throws (ErrorException under Laravel/Symfony, TypeError otherwise) → HTTP 500 instead of 401; the 5.6.1 ConversionFailed catch does not cover it (advisory)
  • PyJWT (USN-9177-1) — non-canonical signature-segment encodings accepted, with possible bypass of token revocation checks. JWT Token Lifecycle and Revocation (USN-9177-1)

Prevention

  • Pin algorithms from configuration, never from the token (RFC 8725 §3.1); each key bound to exactly one algorithm.
  • Pin by kid: select the JWK whose kid matches the header (never the first key); on an unknown kid refresh the JWKS cache once, then reject; publish new keys before signing with them and keep old ones until their tokens expire (JWKS and kid).
  • Never mix HMAC and asymmetric algorithms on one verifier; use typed key objects so cross-family use is refused.
  • Prefer asymmetric signing (RS/ES/EdDSA): the verification key is useless for forgery and no HMAC secret sits in verifier config. If HMAC is used, ≥256-bit CSPRNG secret (32/48/64 bytes for HS256/384/512), rotated, never hardcoded or client-side, distinct per environment, and checked for length at startup (Avada Labs).
  • Bound attacker-controlled cost and fail cleanly: cap PBES2 p2c (or disable PBES2 algorithms), and make every malformed-signature path return a rejection rather than an exception (web-token, lcobucci).
  • Canonical revocation keys: revoke by jti, not by the raw token string, since some libraries accepted non-canonical signature encodings (USN-9177-1).
  • Reject none, unknown algorithms, zero-length keys, and empty/zero-length signatures; compare in constant time.
  • Ignore header key references unless a protocol needs them; then strict parsed-URL allow-lists, no redirects, no cookies, chain validation to a pinned root. Map kid via allow-list only.
  • Assert claims: iss, aud, exp/nbf with tight skew; exact jti semantics; reject unknown crit; keep ID and access tokens non-interchangeable.
  • Lifecycle: short access tokens, rotating/revocable refresh tokens (rotated atomically, reuse revokes the family), invalidation on password reset and logout, HttpOnly/Secure/SameSite cookie scoped by Path or in-memory storage, no tokens in URLs, TLS always; DPoP for sender-constrained tokens (Moorthy).
  • Nothing sensitive in the payload (it is only encoded). Consider phantom/split-token patterns to keep data server-side.
  • Prove fixes with negative tests and re-test after vendor patches (incomplete-patch history).

Tools

  • Testing/forging: jwt_tool (playbook mode, -M pb), Burp JWT Editor, PortSwigger JWT Scanner, JOSEPH (JSON Web Token Attacker), jwt-hack, jwtXploiter, JWTweak, JWTAuditor, jwt-auditor, jwt-pwn, HipaLab/HakLuke client-side suites.
  • Key recovery: rsa_sign2n / sig2n (portswigger/sig2n), JWT-Key-Recover.
  • Cracking: hashcat (-m 16500), John the Ripper, c-jwt-cracker, CookieMonster, Flask-Unsign.
  • References/checklists: OWASP WSTG “Testing JWTs”, RFC 8725 (BCP 225) / rfc8725bis, PortSwigger Web Security Academy, six2dez/Chintan Gurjar/Cyber Frogy pentest checklists.

Sub-pages

Sources