← All guides

JWT security checklist: what to check when you decode a token

Review token claims and check that your service verifies the signature, trusts the right issuer and accepts the token only where it belongs.

Start with the token's intended use

Write down which service issued the token, which component is supposed to accept it and what it represents. An API access token and a token that describes a sign-in can come from the same identity provider while serving different purposes. Record the issuer, expected audience, permitted signing algorithm and required claims for each token type. Use that configuration as the reference when reviewing what you decode.

Open the JWT decoder with a synthetic or expired token. The readable header and claims in a signed compact JWT use unpadded Base64URL. Three segments usually indicate the compact signed form. Five indicate the compact encrypted form, whose claims require decryption. The decoder toolbox can help with separate standard Base64 fields and epoch timestamps you find in the same log.

Mark all decoded claims as unverified in a ticket. Use RFC 7519 for claim semantics and RFC 8725, the JWT Best Current Practice, to review how services establish trust.

Allow only the algorithms configured for this service

Configure the verifier with the explicit set of algorithms allowed for the token profile. Require a signature or MAC for the authentication tokens covered by this checklist and reject none. Enforce one algorithm per verification key and use the declared alg only inside those constraints. Algorithm confusion has allowed verifiers to treat a key meant for asymmetric signature verification as a symmetric MAC key. Check the verifier's configuration and library defaults when upgrading dependencies or adding another issuer.

Verify the signature or MAC server-side on the original compact token using a key you trust for the expected issuer. Fail closed if the cryptographic check fails. Apply the claim and token-type rules before using the token to authorize a request. A signed token can still be for a different API, a different kind of workflow or an account that lacks permission to perform the requested action.

Use distinct validation rules when an issuer provides multiple token types. Enforce the expected type when the profile defines it. For instance, an API implementing the RFC 9068 JWT access-token profile checks the access-token type as part of validation. Treat a generic JWT label as a format hint and check the rest of the profile.

Check issuer, audience and the acceptance window

The time fields use NumericDate in seconds since the Unix epoch. Check the types and values the profile requires. During an incident, compare the verifier and issuer clocks if healthy tokens are rejected near a boundary. Use the server's recorded verification reason to distinguish expiry from type, issuer or audience failures.

Rotate and select signing keys

kid is an untrusted identifier the verifier can use to select a key from the expected issuer's trusted key set. In an OpenID Connect deployment with asymmetric signing, get that set from the configured jwks_uri. Limit lookups to trusted destinations, and treat arbitrary key URLs and key IDs in the token as input. Reject the token if a trusted key remains unavailable after the verifier's normal key refresh.

For a planned rotation, publish the new public verification key, begin signing with the new key ID, and keep the old public key during the overlap required by your valid token lifetimes and verifier caches. Check that verifiers handle both key IDs during the transition. The OpenID Connect rotation guidance describes the handoff. If a signing key is compromised, follow your incident procedure to withdraw trust in that key and invalidate affected credentials.

Keep claims and storage exposure small

Assume a signed token's payload is readable wherever the token travels. Keep passwords, API keys and unnecessary personal data out of the claims. Send bearer tokens over TLS and exclude them from URLs, application logs and support tickets. Use a short lifetime and an audience restricted to the appropriate resource so a leak has a smaller window and scope.

Browser web storage is accessible to scripts on the same origin. Where the architecture allows, keep upstream tokens on a backend-for-frontend and use a Secure, HttpOnly session cookie for the browser. Choose a SameSite policy that supports the sign-in flow and add cross-site request forgery protection for cookie-authenticated state changes. Continue to prevent script injection. Injected scripts can still issue actions through a browser session. See OWASP session management guidance.

Verify the server's decisions

Use the normal sign-in flow with a test issuer and synthetic accounts. Confirm an intended token succeeds and check the server-side rejection reasons for an expired token and a validly signed token issued for a different test API. Test a planned key rotation with applications that already have cached keys. Record which services enforce each rule and which team owns the configuration.

Share only the evidence needed to investigate. A time, request ID, service, failure category and sanitized claim summary can connect the report to server records. If a live bearer token has been exposed, use the provider's revocation or session invalidation procedure and review associated access.

Test invalidation end to end with an ordinary test account. A resource server that only checks an access token's signature and claims can continue accepting a previously issued token until its expiration. Check whether your deployment consults revocation state during verification, and measure how long a previously issued access token remains usable after its session ends. See OAuth token revocation for the trade-offs between token types.

From the channel

Video thumbnail: The Server Handed Me an Admin Key The Server Handed Me an Admin Key Watch safe, hands-on security demonstrations for complete beginners on The Exploit HQ ▸ Video thumbnail: Authentication Bypass Explained — Web Application Security for Beginners Authentication Bypass Explained — Web Application Security for Beginners Watch safe, hands-on security demonstrations for complete beginners on The Exploit HQ ▸