Privacy and Security

JWT Security Checklist: What to Look for in a Token

A practical JWT security checklist based on RFC 8725: algorithms, header keys, expiry, issuer, audience, sensitive claims and secret strength, with fixes.

Saizul Amin
Saizul Amin3 Nov 2026 · 4 min read
JWT Security Checklist: What to Look for in a Token

JWT Security Checklist: What to Look for in a Token

JSON Web Tokens are everywhere in modern authentication, and most of the security problems around them are not exotic cryptography but configuration choices. Tokens live too long, lack an audience, carry data they should not, or are signed with a secret copied from a blog post. RFC 8725, the IETF's best current practice for JWTs, lists the main pitfalls. This checklist walks through them, and the free JWT Security Analyzer applies them to a token you own.

1. The algorithm

The alg header names the signature algorithm. Three rules cover most cases:

  • Never accept alg none in production. An unsigned token can be forged by anyone.
  • Your verifier should allow one algorithm, or a short fixed list, chosen in your configuration, never taken from the token itself.
  • Prefer asymmetric algorithms such as ES256, EdDSA or RS256 when more than one service verifies tokens. With HS256, every service that can verify a token can also create one.

2. Keys referenced in the header

Headers can carry key hints: kid to choose a key, jwk to embed one, and jku or x5u to point at a URL. Embedded keys and key URLs are dangerous if the verifier trusts them, because the token's author picks the key. Treat kid as an opaque label looked up in a list you control, and ignore jwk, jku and x5u unless you match them against an exact allow-list. A kid that contains slashes, dots or quotes is a hint that it may be used in a file path or database query, which invites injection.

3. Expiry and lifetime

Every access token should have exp. Typical lifetimes are 5 to 60 minutes, with refresh tokens for longer sessions. A token valid for 30 days is as good as a password for 30 days if it leaks. Also watch for exp written in milliseconds instead of seconds, which many libraries read as a date thousands of years away, and for iat values in the future, which point to clock problems.

4. Issuer and audience

iss says who issued the token and aud says who it is for. Verifiers must check both. Without an audience check, a token meant for a low-risk internal app can be replayed against a sensitive API that trusts the same identity provider. Long audience lists and wildcards widen the blast radius in the same way. ID tokens from OpenID Connect should also carry a nonce that the client checks.

5. What goes in the payload

A signed JWT is not encrypted. Anyone who sees the token, including browser extensions, proxies and log pipelines, can decode the payload. Keep passwords, secrets, card numbers and national ID numbers out of it entirely, and think twice about email addresses and phone numbers. If the client does not need a value, leave it on the server.

6. HMAC secret strength

For HS256 the secret should be at least 32 random bytes, for HS512 at least 64, as RFC 7518 requires. A short or well-known secret can be tested offline against any captured token, with no rate limit. Generate secrets with a cryptographic random generator and store them in a secrets manager.

Running the analyzer

  1. Paste a token from your own system.
  2. Set your policy: token type, maximum lifetime, expected issuer and audience, clock skew.
  3. Optionally paste your HMAC secret, public key, certificate or JWK to verify the signature.
  4. Read the findings, which are sorted from critical to informational, each with a fix.
  5. Download or print the report for your ticket or code review.

The analyzer only rates the secret you type, by length and against a short list of placeholders from tutorials. It does not guess or search for secrets. The second tab signs test tokens with your own keys, which is useful for unit tests that check your verifier rejects bad audiences or expired tokens.

Test the verifier too

A clean token proves little if the code that accepts it is lax. Add tests that feed your API a token with the wrong audience, an expired token, a token signed by an unknown key and a token with a changed payload, and make sure every one is rejected. Use a maintained library, keep it updated, and configure the allowed algorithms explicitly.

Handle tokens carefully

A live token is a credential. The analyzer runs locally and sends nothing anywhere, but a token pasted into any tool, chat or ticket can be replayed until it expires. Prefer expired or test tokens for reviews, and clear the input when you are done.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages