Inspect JSON Web Tokens
Learn the anatomy of JSON Web Tokens, the risks of the 'none' algorithm, and why you should never store sensitive data in claims.
A JSON Web Token (JWT) is split into three parts separated by dots (.): Header.Payload.Signature.
exp (expiration).The Header and Payload are encoded using Base64Url, which means they are publicly readable by anyone.
alg: "none" header. Attackers could decode a token, elevate their privileges in the payload, set the algorithm to "none", and strip the signature entirely to bypass authentication.JWTs are popular because they are stateless. The backend server does not need to look up a session ID in a database. Instead, it simply verifies the cryptographic signature of the token using its secret key (or public key for RSA). If the signature is valid, the claims inside the token are trusted.
The JWT standard defines several reserved "Claims" (keys in the payload JSON):
iss (Issuer): Who created the token.sub (Subject): Who the token refers to (usually the User ID).exp (Expiration Time): A Unix timestamp of when the token expires.aud (Audience): Who the token is intended for.exp claim.If you intercept a JWT over the network, can you read the data inside the payload?