JSON Web Token
A signed, self-contained token that carries claims a server can verify without a database lookup.
JSON Web Token is a compact, signed data structure — three base64url segments joined by dots: a header, a payload of claims, and a signature — that a server can verify cryptographically without looking anything up in a database. That's its entire value proposition: a session ID is a pointer that means nothing until you look it up; a JWT is self-contained, carrying the claims (user ID, roles, expiry) directly, verifiable by anyone holding the signing key or, for asymmetric signatures, the public key alone.
That self-containedness is also its sharpest edge. Because a valid JWT is trusted on the signature alone, revoking one before its stated expiry is genuinely hard — there's no session store to delete a row from. Systems that need real-time revocation (someone's access must end now, not when the token expires) end up building a denylist or a short-token-plus-refresh-token scheme anyway, which quietly reintroduces the server-side state JWTs were meant to avoid. Keeping expiry windows short is the usual mitigation, not a fix.
The other recurring failure is trusting the token's own unverified header. Early JWT libraries let the alg field in the header claim none or switch algorithms, and code that read the algorithm from the token instead of hardcoding what it expected could be tricked into skipping verification entirely. The fix is mundane and non-optional: a verifier must dictate the algorithm itself and never take it from the token being verified.
JWTs commonly carry OAuth and OpenID Connect identity claims, and get passed as a bearer token in an Authorization header — a choice with a real tradeoff: an HttpOnly cookie is the one storage a Cross-Site Scripting payload cannot read (its weakness is CSRF, since the browser attaches it automatically), while a bearer token sent from JavaScript must live somewhere script-accessible like localStorage or memory, where any XSS can exfiltrate it.
See also4
OAuth
A protocol for granting one application limited access to a user's data on another, without handing over the user's password.
Web Platform5 connections
Cross-Site Scripting
Injecting attacker-controlled script into a page that a victim's browser then executes with the victim's own privileges.
Web Platform6 connections
Same-Origin Policy
The browser rule isolating documents by scheme, host, and port, and the mechanisms for relaxing it.
Web Platform15 connections
Content Security Policy
An HTTP header that tells the browser which sources of script, style, and other content a page is allowed to load.
Web Platform6 connections
Related1
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from4
- Content Security PolicyWeb Platform
An HTTP header that tells the browser which sources of script, style, and other content a page is allowed to load.
- Cross-Site ScriptingWeb Platform
Injecting attacker-controlled script into a page that a victim's browser then executes with the victim's own privileges.
- OAuthWeb Platform
A protocol for granting one application limited access to a user's data on another, without handing over the user's password.
- Zero Trust NetworkNetworks & Distribution
Zero trust authenticates and authorizes every request individually, treating network location as no proof of anything.