JSON Web Tokens (JWT)

security OpenTrojan Threat Intelligence

JWT as a stateless token format: structure, signature verification, common vulnerabilities (alg confusion, clock skew, leaked secrets) and mitigation.

Quick Answer

A JWT is a signed token; reject it if the signature does not verify against the expected key, the algorithm is tainted/confused (e.g., 'none' or mismatched alg), the issuer/audience is wrong, or the token is expired.

Definition

A JWT is a compact, signed claims token (header.payload.signature) used mainly as a stateless bearer token; its security depends entirely on rigorous signature verification and short lifetimes.

What it is

A JSON Web Token (RFC 7519) is a compact, URL-safe token of three base64url parts — header, payload, signature — commonly used as a stateless bearer token in APIs and SSO (see security:oauth-saml-sso).

Why it matters

Statelessness is convenient, but a JWT’s only real security boundary is its signature. If a library or application trusts a token without verifying the signature, accepts the wrong algorithm, or uses a leaked or attacker-controlled signing key, anyone can mint a token with arbitrary claims.

How it works

  • header: token type and signing algorithm (alg).
  • payload: claims — issuer (iss), audience (aud), subject (sub), expiry (exp), issued-at (iat).
  • signature: HMAC (symmetric shared secret) or asymmetric (RSA/ECDSA public key).

Detection

  • alg: none or an algorithm mismatch between header and the expected key type (alg-confusion).
  • Tokens with a exp in the past being accepted, or no expiry at all.
  • iss/aud not matching the expected identity provider / relying party.
  • Two users sharing a symmetric-signature token (suggests a shared secret was exposed).

Mitigation

  • Verify the signature with the expected algorithm and key; never accept alg: none or fall back to an untrusted algorithm.
  • Validate iss, aud, sub, exp and iat; reject expired and early (skew) tokens.
  • Use asymmetric signing so secret material is confined to the signer; rotate keys.
  • Do not log tokens; they are bearer credentials.

Investigation

Decode the JWT (header/payload only, never the signature) to inspect alg/claims and confirm validation gaps, then review the issuer’s key-servicing and token-history logs. Use guides:tool-jwt-guide to decode safely and guides:decode-jwt-safely for the safe procedure.

References

Have a follow-up question?

Ask OpenTrojan's evidence-backed assistant about this topic — answers cite their sources.

Ask AI about this Start an investigation