Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
A JSON Web Token is a compact, signed set of claims that a service can verify without calling back to the issuer. Its convenience is also the source of most JWT bugs.

What Is a JSON Web Token?
A JSON Web Token is three base64url-encoded segments separated by full stops: a header saying how it was signed, a payload of claims, and a signature over the first two. RFC 7519 defines it, and it is now the default currency of API authentication, OpenID Connect identity assertions, and session state in distributed systems.
The appeal is that verification is local. A service that holds the right key can check the signature and read the claims without a network call to the issuer, which is exactly what you want when forty microservices need to make authorisation decisions a thousand times a second.
{
"alg": "RS256",
"typ": "JWT",
"kid": "2024-prod-a"
}
.
{
"iss": "https://login.example.co.uk",
"sub": "4f9c21e0-88b1-4c3a-9c0e-3a1d2b7f6e54",
"aud": "https://api.example.co.uk/payments",
"exp": 1763208000,
"iat": 1763204400,
"scope": "payments.read payments.write"
}
Note what the payload is not: encrypted. Base64url is an encoding, not a cipher, and anyone holding the token can read every claim in it. Putting a national insurance number, a home address, or an internal database identifier in a JWT discloses it to the client and to anything that logs the request. Where claims genuinely must be confidential, the answer is JSON Web Encryption rather than hope.
The most common vulnerability class is not a broken algorithm but an incomplete check. A correct validator confirms, in order:
kid from a key set you fetched from a trusted source—never from a URL supplied in the token itself.iss is an issuer you trust.aud names this specific service. Accepting a token minted for another API is how a low-value service becomes a route into a high-value one.exp has not passed, and nbf has, allowing a small clock skew of a minute or so rather than an hour.nonce matches the one you sent.The none algorithm. RFC 7519 permits alg: none for unsecured tokens. Libraries that honoured it would accept a token with no signature at all, letting an attacker rewrite claims freely. Most libraries now refuse it by default, but the pattern recurs in hand-rolled validators.
Algorithm confusion. A service configured for RS256 verifies with a public key. An attacker changes the header to HS256 and signs the token using that public key as the HMAC secret. A naive library that selects the verification algorithm from the token header will accept it, because the public key is public. Our entry on JWT algorithm confusion covers this in detail.
Weak HMAC secrets. HS256 tokens signed with a short or guessable secret can be cracked offline with hashcat in minutes. If you use symmetric signing, the secret needs the entropy of a cryptographic key, held in a secrets manager, not a value from a configuration file.
Header injection. The jku and x5u header parameters point at a key set URL, and jwk embeds a key directly. A validator that trusts any of them is letting the attacker supply the verification key. Allow-list the key source.
Stateless verification means a valid, unexpired token keeps working after you disable the account, because no service asks the issuer anything. An attacker with a stolen token therefore has access until expiry regardless of what you do to the user record.
Nobody has solved this elegantly. The workable combination is short access token lifetimes—five to fifteen minutes—with longer refresh tokens that are checked against server-side state, a denylist of revoked token identifiers for the brief window that matters, and continuous access evaluation where your platform supports it. Token introspection reintroduces the issuer call for high-value operations, trading some performance for immediate revocation.
Sender-constrained tokens address the other half of the problem. Binding a token to a client-held key with DPoP, or to a certificate with mutual TLS, makes a stolen token useless rather than merely short-lived.
One storage note that is routinely got wrong in browsers: a token in localStorage is readable by any script on the page, so a single cross-site scripting flaw becomes full account takeover. Prefer a cookie marked HttpOnly, Secure, and SameSite.
At Privia Security, we test token issuance and validation logic as part of our web application security services.
No. The header and payload are base64url-encoded, which is reversible by anyone holding the token, including the client and anything that logs it. A signed JWT guarantees integrity and origin, not confidentiality. If claims must stay secret, use JSON Web Encryption, or keep the sensitive value server-side and put an opaque reference in the token instead.
You cannot revoke the token itself, because services verify it locally without contacting the issuer. The practical approach is short access token lifetimes of a few minutes, refresh tokens validated against server-side state, a short-lived denylist of revoked token identifiers, and introspection for high-value operations. Continuous access evaluation shortens the window further where the platform supports it.
Avoid it in browsers. Anything in localStorage is readable by any JavaScript running on the page, so one cross-site scripting flaw turns into complete account takeover. A cookie with the HttpOnly, Secure, and SameSite attributes keeps the token out of reach of page scripts, at the cost of needing cross-site request forgery protection on state-changing requests.
The aud claim names the service the token was issued for, and each service must reject tokens that name a different audience. Without that check, a token obtained legitimately for a low-value API can be replayed against a high-value one that shares the same issuer. It is one of the cheapest validation steps and one of the most frequently omitted.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.