A JWT carries its own instructions for checking it: the first segment tells the verifier which algorithm to use. That segment, and the claims after it, are not encrypted. They are JSON that has only been Base64URL-encoded, so anyone who holds the token can read them. This article covers why the format was designed this way, what the signature does and does not protect, and why trusting the token's own alg value led to years of attacks.
Three segments, two of them plain JSON
A signed JWT uses the JWS Compact Serialization defined in RFC 7515. It is three Base64URL strings joined by dots:
BASE64URL(header) . BASE64URL(payload) . BASE64URL(signature)
Base64URL is the "URL and filename safe" alphabet from RFC 4648, section 5. It is ordinary Base64 with - and _ in place of + and /. RFC 7515 also drops the trailing = padding, so the token can go into a URL, a cookie or an HTTP header without being escaped. The Base64 encoder can encode or decode in either the standard alphabet or Base64URL, so you can compare the two on the same input.
This is an encoding, not a cipher. RFC 7519 defines a JWT as claims carried either as the payload of a JWS (signed) or as the plaintext of a JWE (encrypted). The everyday "eyJ…" token is the signed kind, and as the jwt.io introduction also points out, signing protects it from tampering but does not hide it. That is why secrets do not belong in a signed token's claims.
The Token anatomy line in the JWT Decoder colours the three pieces separately. The tool decodes the first two as JSON. It shows the third but never reads it, because without a key there is nothing to check it against.
The browser decoding trap
In a browser, the obvious way to decode a segment is atob(). It returns a "binary string" with one character per byte, which is not the same as text. For pure ASCII claims you cannot tell the difference. A name with diacritics, though, is stored as multi-byte UTF-8, so the raw atob() output turns it into garbage.
The fix is to turn that string back into bytes and decode them as UTF-8. The decoder does this with TextDecoder in its default, non-fatal mode. Under the WHATWG Encoding Standard, that mode replaces malformed byte sequences with U+FFFD (the replacement character) instead of throwing an error. So a damaged segment can still decode, with visible replacement marks where bytes were invalid.
Where JWT came from: JOSE and OpenID Connect
JWT belongs to the JOSE family of specifications, published together in May 2015: JWS (RFC 7515), JWE (RFC 7516), the algorithm registry JWA (RFC 7518) and JWT itself (RFC 7519). RFC 7519 is a Proposed Standard by M. Jones, J. Bradley and N. Sakimura. It also notes that the suggested pronunciation of JWT is the same as the English word "jot".
The format's best-known job came slightly earlier. OpenID Connect Core 1.0, finalised in February 2014, states that "the ID Token is represented as a JSON Web Token (JWT)". Because OIDC was built on the JWT drafts, it made the format the identity token behind many "Sign in with…" flows before the RFC had its number.
Claims: registered, public and private names
The payload is a JSON object of claims. RFC 7519 sorts claim names into three kinds:
- Registered:
iss(issuer),sub(subject),aud(audience),exp(expiration),nbf(not before),iat(issued at) andjti(JWT ID). None are mandatory by themselves. Profiles such as OIDC decide which are required. - Public: names registered with IANA, or names that are collision-resistant, for example a URI you control.
- Private: names that the producer and consumer simply agree on.
Claim names are case-sensitive, so Exp is not exp. The IANA JWT Claims registry holds far more than the seven registered names, with entries from OpenID Connect, OAuth and other specifications. A real token often carries a dozen claims or more.
OpenID Connect adds auth_time (when the user authenticated), nonce and azp (the authorized party, the client the token was issued to). It also adds profile claims such as name, email and updated_at. That ecosystem explains what the decoder's Claims explained table recognises. It resolves auth_time and updated_at as dates alongside exp, nbf and iat, and gives plain-language meanings for names such as azp, scope, email, role and roles. The Claims tile counts top-level keys only, so a nested object counts as one.
Vendor tokens add their own names. Microsoft Entra ID access tokens carry claims such as scp, oid and tid. Even so, Microsoft's documentation tells client applications to treat access tokens as opaque strings: the contents are meant for the API that receives them, and some tokens a Microsoft API receives might not be decodable JWTs at all.
NumericDate: seconds, not milliseconds
RFC 7519 defines time claims as a NumericDate: a JSON number of seconds since 1970-01-01T00:00:00Z UTC, ignoring leap seconds. The background on that epoch, and on why leap seconds are left out, is in what Unix time actually counts.
The validation rules are short. The current time MUST be before exp, and MUST be after or equal to nbf. Implementations MAY allow a small leeway for clock skew, which RFC 7519 says is usually no more than a few minutes.
A decoder can only compare those numbers with the clock of the machine it runs on. The JWT Decoder uses your local clock with no leeway. It checks nbf before exp, and it counts an exp equal to the current second as already expired. So its badge ("Valid now", "Expired", "Not valid yet" or "No expiry claim") can disagree with a server that allows a minute or two of skew. A token with no numeric exp has no stated lifetime. That is not the same as being valid forever.
Units are a common source of confusion. A timestamp in milliseconds, read as seconds, points tens of thousands of years into the future. JavaScript itself has a limit as well: per ECMA-262, a Date covers ±8.64 × 10¹⁵ milliseconds around the epoch, up to +275760-09-13, and toISOString() throws a RangeError for anything outside that range. If you are chasing a rejected token rather than reading about the format, the guide why an API rejects a JWT walks through exp, aud, iss and alg one by one.
What the signature actually covers
RFC 7515 defines the JWS signing input as an ASCII string:
ASCII(BASE64URL(UTF8(header)) || '.' || BASE64URL(payload))
The signature is computed over those exact characters. That is why a token cannot be "tidied up". Reordering keys, changing whitespace or re-encoding the JSON produces a different signing input, and the original signature no longer matches it.
The alg value names the signing algorithm, and with it the kind of key involved. RFC 7518 defines HS256 as HMAC with SHA-256, RS256 as RSASSA-PKCS1-v1_5 with SHA-256, and ES256 as ECDSA with the P-256 curve and SHA-256:
| Algorithm | Key type | Who can create a valid signature | Who can verify |
|---|---|---|---|
| HS256 | One shared secret | Anyone holding the secret | Anyone holding the same secret |
| RS256 | RSA key pair | Only the holder of the private key | Anyone with the public key |
| ES256 | Elliptic-curve key pair (P-256) | Only the holder of the private key | Anyone with the public key |
With HMAC, every party that can verify can also sign. With RSA or ECDSA, the issuer keeps the private key and can publish the public key freely.
Decoding needs no key, but verifying always does. A decoder can therefore tell you what a token says, but never who wrote it. That is the reason for the decoder's permanent note that decoding does not verify the signature.
RFC 7519 also defines an Unsecured JWT: the header says "alg": "none" and the third segment is empty, so the token ends with a dot (header.payload.). RFC 8725 says such tokens should be accepted only when the application explicitly expects unsecured tokens, for example when the JWT is already protected by some other means.
When the token picks its own algorithm
The header that tells the verifier how to check the token arrives inside the token. If a library reads alg from the header and acts on it, the attacker chooses how their own forgery gets checked.
Tim McLean's widely cited write-up on the Auth0 blog described two library flaws that followed from this:
noneaccepted as valid. Some libraries treated a token withalgset tononeand the signature removed as verified, so anyone could forge a token with any payload.- RSA/HMAC confusion. A server expects RS256 and holds the issuer's public RSA key. The attacker changes
algto HS256 and computes an HMAC over the token, using that public key as the "secret". A library that picks the method from the header runs HMAC verification with the same public key bytes, and the forged token passes.
The fix McLean proposed is the one now generally recommended: the verifier, not the token, decides which algorithms are acceptable, in its own configuration.
RFC 8725, published in February 2020 as Best Current Practice 225, collects these and other lessons. Its recommendations include:
- Let callers pass an allow-list of algorithms to the library, and use that list in every application.
- Validate every cryptographic operation, including those in nested tokens.
- Always check
issandaud, so a token issued for one service cannot be replayed against another. - Use explicit typing with the
typheader, so one kind of JWT cannot be passed off as another. - Treat header parameters that point at keys, such as
jku,jwk,x5uandkid, as attacker-controlled.
For a hands-on view, PortSwigger's Web Security Academy has labs on these classes. They cover injecting a key through jwk or jku, abusing kid, algorithm confusion, and brute-forcing weak HS256 secrets offline. A short shared secret is exposed this way because anyone holding one valid token can test guesses without contacting the server.
You can see why alg counts as input, not as a fact, in the JWT Decoder. Load the RS256 header example: the header names RS256, but the signature is the Base64 of the word "signature".
The Algorithm tile still reports RS256, because it shows whatever the header claims, including none. That is a reading of untrusted data, not a verdict on the token.
Correct code, broken library: the 2022 blank-signature bug
An application can follow every rule in RFC 8725 and still be let down by the cryptographic library underneath. CVE-2022-21449, which Neil Madden named "Psychic Signatures", was a flaw in Java's ECDSA verification. Madden's write-up shows that a signature with both values r and s equal to 0 was accepted as valid for any message and any public key. Java 15 to 18 were affected until the April 2022 Critical Patch Update.
ES256 JWTs use exactly this kind of signature, in a raw fixed-length encoding. A service verifying ES256 tokens on an unpatched runtime would accept a token whose signature segment was nothing but zero bytes. The algorithm was pinned correctly, but the check itself was broken.
Five segments: encrypted and nested tokens
When claims must stay confidential, the JOSE answer is JWE (RFC 7516). Its compact serialization has five Base64URL parts:
protected-header . encrypted-key . initialization-vector . ciphertext . authentication-tag
Only the protected header is readable. The claims sit inside the ciphertext and need the key. RFC 7519 also allows nesting: a JWT can be signed and then encrypted, with the inner JWS as the JWE plaintext.
The JWT Decoder is built for signed tokens. Given a five-part token, it tries to read the first two segments as header and payload. Since the second segment is an encrypted key, not JSON, the tool cannot show the contents and will most likely report Invalid JWT — could not decode.
The critics, and formats without an alg header
JOSE has outspoken critics. In No Way, JOSE! (2017), Scott Arciszewski of Paragon Initiative Enterprises argues that the family offers too many risky options, and that letting the header choose the algorithm is the root of several attack classes. The post says algorithm choices should be made by cryptographers rather than left to developers, and Paragon later proposed PASETO as a simpler alternative. It is one company's argument, not a consensus.
The PASETO specification shows the other design choice in concrete form. A PASETO token looks like this:
version.purpose.payload[.footer]
The version fixes the cryptography, and the purpose says whether the token is local (symmetric, encrypted) or public (signed). In v4, public tokens use Ed25519 signatures and local tokens use XChaCha20 with BLAKE2b. There is no negotiable alg field, so none and RSA/HMAC confusion cannot happen by design. The trade-off is that changing the cryptography means moving to a new version.
A third approach is to keep the token opaque: a random reference that the resource server looks up, or checks with the issuer through OAuth 2.0 Token Introspection (RFC 7662). Opaque tokens are easy to revoke because the server holds the state, but every check costs a lookup or a network call. A self-contained JWT avoids that call, at the price of being hard to revoke before its exp. Revoking it early needs server-side state such as a deny-list. Short lifetimes do not revoke anything, but they limit how long a stolen token stays usable. Neither model wins outright: the choice depends on how many services verify tokens and how quickly a revocation must take effect.
Privacy
The JWT Decoder decodes in your browser and makes no network calls, but a live token is still a bearer credential that works for whoever holds it until it expires, so use expired or test tokens in screenshots and bug reports, whichever decoder you use.
FAQ
Is a JWT encrypted, or only encoded?
A signed JWT (JWS) is only encoded. Its header and payload are Base64URL-encoded JSON, so anyone holding the token can read them. Confidentiality needs JWE, a separate five-part format whose claims cannot be read without the key.
What is the practical difference between HS256 and RS256?
HS256 is an HMAC with one shared secret, so every party that can verify a token can also create one. RS256 uses an RSA key pair: only the holder of the private key can sign, while anyone with the public key can verify. That makes RS256 a better fit when many services must check tokens but only one should issue them.
Why does the JWT standard allow alg none at all?
RFC 7519 defines Unsecured JWTs for cases where integrity is already provided some other way, for example by the channel that carries them. RFC 8725 says they should be accepted only when the application explicitly expects them. The historical problem was never the definition itself, but libraries accepting none when the application expected a signature.
Can a JWT be revoked before its exp time?
Not by the token alone. A self-contained JWT stays valid for any verifier that checks only its signature and times until exp passes. Revoking it early needs server-side state, such as a deny-list. Short lifetimes with refresh tokens limit the damage, because revocation then applies to the refresh token. Alternatively, you can use opaque tokens with introspection (RFC 7662).
How is a JWE different from a signed JWT?
A signed JWT has three segments and readable claims. The signature proves integrity and origin. A JWE has five segments (protected header, encrypted key, IV, ciphertext and authentication tag), and its claims stay hidden without the decryption key. A JWT can also be signed first and then encrypted as a nested token.
Is PASETO a drop-in replacement for JWT?
No. PASETO uses a different layout (version.purpose.payload[.footer]) and fixed cryptography per version, with no alg header. Software that expects a JWT cannot read it. It solves the algorithm-confusion problem by design, but adopting it means changing both the issuer and every consumer.