Security & Utilities9 min technical readUpdated 2026-11-29

JSON Web Tokens (RFC 7519) in Production: Claims, Signature Verification & Storage Security

Signed JSON Web Tokens (JWS) are readable by anyone who intercepts them. Learn how JWT segments are encoded, why decoding is never verification, and how to avoid classic production auth vulnerabilities.

By DevToolbox Engineering Team • Published by SummitStore Digital Products

Anatomy of a Signed JWT: Header, Payload, and Signature

A compact JSON Web Token (RFC 7519) signed under JSON Web Signature (RFC 7515) consists of three dot-separated segments: header.payload.signature. Both the header and payload are plain UTF-8 JSON objects encoded using Base64url (RFC 4648 Section 5, substituting - and _ for + and / and omitting = padding).

Crucially, a standard signed JWT (JWS) provides integrity and authenticity—not confidentiality. Anyone with access to the token string can Base64url-decode the first two segments in microseconds without possessing any cryptographic key. Never place passwords, database secrets, or unmasked PII inside a JWS payload unless wrapped in JSON Web Encryption (JWE).

Because production Bearer tokens grant live API access until they expire, pasting tokens into server-backed debugging websites is a severe operational security leak. Always inspect JWT headers and claims inside a strictly offline, client-side decoder.

Structure of a Decoded RFC 7519 JWT
// Segment 1: JOSE Header
{
  "alg": "RS256",
  "typ": "JWT",
  "kid": "2026-prod-signing-key-01"
}

// Segment 2: Registered & Custom Claims Payload
{
  "iss": "https://auth.example.com",
  "sub": "usr_01936b8e",
  "aud": "https://api.example.com",
  "iat": 1764410000,
  "exp": 1764410900
}

Decoding vs. Cryptographic Verification: Preventing alg Attacks

Calling a base64 decoder—or jwt.decode() in backend libraries—merely parses JSON strings; an attacker can edit "role": "admin", re-encode the payload, and pass any decode-only check. Your API server must call a cryptographic verification routine (such as jose.jwtVerify) using a trusted key.

Historically, two catastrophic implementation flaws plagued JWT libraries: accepting "alg": "none" (treating an empty signature as valid) and RS256-to-HS256 algorithm confusion (where an attacker tricks a server into using its public RSA key bytes as a symmetric HMAC secret).

To eliminate algorithm confusion completely, always hardcode an explicit allowlist of permitted algorithms (for example, algorithms: ['RS256'] or ['EdDSA']) in your verification call rather than trusting the unverified header's alg field.

Validating exp, nbf, iss, and aud Claims Correctly

A valid cryptographic signature only proves that your identity provider issued the token at some point—it does not prove the token is meant for your service or is still valid right now.

Every resource server must validate four registered claims: exp (Expiration Time, Unix epoch seconds—not milliseconds!), nbf (Not Before), iss (Issuer URI), and aud (Audience identifier). Skipping aud validation allows a token minted for a low-privilege analytics service to be replayed against a billing service sharing the same IdP.

Where to Store Tokens in Browser Applications

Storing long-lived JWTs in window.localStorage exposes them to immediate theft if a single Cross-Site Scripting (XSS) vulnerability or compromised third-party script executes on your origin.

Modern web architectures prefer keeping short-lived access tokens (5–15 minutes) in JavaScript closure memory while storing rotating refresh tokens inside HttpOnly, Secure, SameSite=Lax/Strict cookies managed by a Backend-for-Frontend (BFF) endpoint.

Common JWT Signing Algorithms Compared

AlgorithmKey TypeSigning Key DistributionRecommended Usage
HS256 (HMAC + SHA-256)Symmetric shared secretBoth issuer & verifier hold secretSingle monolith or tightly coupled internal service
RS256 (RSASSA-PKCS1-v1_5)Asymmetric RSA (2048+ bit)Private key signs; JWKS public key verifiesMulti-service OAuth2 / OIDC architectures
ES256 (ECDSA P-256)Asymmetric Elliptic CurvePrivate key signs; compact 64B signatureBandwidth-sensitive mobile & distributed APIs
EdDSA (Ed25519)Asymmetric Edwards CurveFast deterministic signing, small keysModern high-throughput zero-trust microservices

Production Engineering Checklist

  • Treat signed JWTs (JWS) as signed postcards—anyone can read the payload, so never store secrets inside claims.
  • Enforce an explicit server-side algorithm allowlist and validate iss, aud, and exp on every request.
  • Ensure symmetric HS256 secrets contain at least 256 bits of cryptographic entropy (32 random bytes).
  • Debug production tokens exclusively in client-side tools so active credentials never hit third-party access logs.

Frequently Asked Questions

Why are JWT exp and iat timestamps 10 digits instead of 13 digits?

RFC 7519 NumericDate specifies Unix epoch time in seconds (10 digits), whereas JavaScript Date.now() returns milliseconds (13 digits). Multiply exp by 1000 before passing it to new Date(exp * 1000).

How can I revoke a stateless JWT before it expires?

Keep access token lifetimes short (5–15 minutes) so natural expiration handles most cases, and maintain a fast Redis deny-list keyed by jti (JWT ID) or user security-stamp version for immediate forced logouts.