Why check a token for weaknesses
JWTs are simple, and that simplicity hides traps. Many real incidents with JWTs came not from broken cryptography but from choices: a verifier that accepted alg: none, a secret copied from a tutorial, a token that never expires, a password put into a claim.
Most of these choices leave traces in the token itself. This checker reads the header and payload, tries a short list of well-known HMAC secrets, and reports what it finds, most serious first.
What the checker looks for
| Finding | Why it matters |
|---|---|
alg: none | The token is unsigned; anyone can write one |
| Signed with a well-known secret | Anyone can forge tokens with that secret |
| HMAC algorithm | Every verifier can also create tokens |
| Empty signature | The header claims a signature that is not there |
jku or x5u in the header | Points the verifier to keys chosen by the sender |
jwk or x5c in the header | Carries its own key, which proves nothing |
Unusual characters in kid | May be an injection attempt against a key lookup |
No exp, or a very long lifetime | A stolen token stays useful for too long |
No iss or aud | Verifiers cannot tell who issued it or who it is for |
| Claims that look secret | Anyone holding the token can read them |
| Larger than 4096 bytes | Will not fit in one cookie |
The attacks behind the findings
The none algorithm
RFC 7518 defines none for tokens whose integrity is protected some other way. A verifier that reads alg from the token and honors none accepts any token an attacker writes. Correct verifiers have a fixed list of allowed algorithms and never include none.
Algorithm confusion
If a verifier lets the token choose the algorithm, an attacker can take the issuer’s RSA public key, which is public, and use it as an HMAC secret to sign a token with HS256. A naive verifier then “verifies” it with the same public key. Pinning the algorithm and checking that the key type fits prevents this.
Keys supplied by the token
The jku, x5u, jwk and x5c header parameters let a token name or carry a key. If a verifier trusts them, an attacker signs with their own key and points to it. Keys must come from the verifier’s configuration, such as the issuer’s JWKS URL.
Guessable secrets
An HS256 token can be checked against a candidate secret offline, as fast as a computer can compute HMACs. Short secrets, words and defaults from documentation fall quickly. RFC 7518 requires at least 32 bytes for HS256, and they should be random.
How to check a token
- Paste the token. A deliberately weak sample is filled in so you can see the findings.
- For an HMAC token, optionally enter your secret. The tool reports its length and whether it verifies the token.
- Read the findings, from serious to informational.
- Fix each serious finding in the issuer or in the verifier, then check a new token.
The weak-secret test tries 29 secrets seen in tutorials, defaults and sample code. A match means the secret must be replaced. No match does not mean the secret is strong.
What a clean Keycloak token looks like
A Keycloak access token is signed with the realm’s private key, RS256 by default, so the shared-secret findings do not apply. It has exp, iat, iss and jti, and a kid in the header that matches the realm’s certs endpoint. It never carries jku, x5u or an embedded key.
The findings that do appear on Keycloak tokens usually come from configuration:
- Long lifetimes, when Access Token Lifespan was raised to hours to avoid refresh logic.
- Missing or broad audience, when no Audience mapper names the API.
- Data that should stay private, added by custom mappers from user attributes.
- Large tokens, from many groups or client roles.
Use cases
Reviewing a third-party integration
When a partner sends you tokens, check one here before you write the verifier. HMAC with a shared secret, missing audience or long lifetimes are things to raise early.
Auditing your own issuer
Check tokens from each of your issuers, including small internal services that sign their own tokens. Those are where defaults like secret survive.
Teaching the team
The sample token on this page shows several mistakes at once. It is a quick way to show why each check exists.
What the checker cannot see
Most JWT vulnerabilities live in the verifier, not the token. This tool reads tokens only. It cannot tell whether your API pins the algorithm, fetches keys safely, checks aud, or handles key rotation. Review the verifier code and its library configuration as well.
A clean result means the token shows none of these signs. It does not mean the system that issues or accepts it is secure.
Fixes, finding by finding
alg: noneaccepted: configure the verifier with an explicit list of algorithms.- Weak or known secret: replace it with 32 or more random bytes, and treat existing tokens as compromised.
- Shared secret across many services: move to RS256 or ES256 so only the issuer can sign.
- Key URL or key in the header: ignore these parameters; take keys from configuration only.
- No expiry or long lifetime: set short access token lifetimes and use refresh tokens.
- Missing audience: add an audience for each API and check it on every request.
- Secrets in claims: remove them; JWT payloads are readable by anyone.
A verifier configuration that avoids these problems
Most JWT libraries can be configured safely. The settings below exist under different names in almost every one of them.
issuer: https://auth.example.com/realms/acme
audience: orders-api
algorithms: [RS256]
jwks_uri: https://auth.example.com/realms/acme/protocol/openid-connect/certs
clock_tolerance: 30s
required claims: exp, iat, iss, aud, subWith a fixed algorithm list, keys only from the configured jwks_uri, and required issuer and audience, the attacks described above have nothing to work with.
Reading the sample findings
The sample token on this page is made up and deliberately weak. It shows several findings at once.
- It is signed with HS256 using the secret
secret, so anyone can forge it. - It has no
exp, so it never expires. - It has no
aud, so any service trusting the issuer would accept it. - It carries a
passwordclaim, readable by anyone who holds it.
Paste a token from your own issuer to compare. A well-configured Keycloak realm’s access token should show only informational notes.
Severity levels
Findings come in four levels. Fail means anyone could forge, replay or read something they should not. Warning means a risky choice that is acceptable only with a good reason. Note is information worth knowing. Pass confirms a check that went well. Fix every Fail before relying on the tokens.
Privacy
All checks run in your browser, including the weak-secret test. Nothing is sent to us. If you enter your own secret, use a test secret; a production secret should never be typed into a web page.