Back to Technical Mode
JWT Tampering
A JSON Web Token is base64url-encoded, not encrypted — its header and payload are plainly readable by anyone. Trust comes entirely from a signature the client cannot forge without the server's secret.
Header.Payload.Signature — only the signature is cryptographically protected
Editing the payload (e.g. changing "role":"user" to "role":"admin") invalidates the signature
The 'alg':'none' attack tries to convince a server to skip verification entirely
Servers must pin the expected algorithm and never trust an algorithm named in the token itself
Want this flow explained in detail as it plays?
Editable Token
..(empty)
Header
Signature
HMAC-SHA256(header.payload, server_secret) — recomputed server-side, never trusted from the client.
Edit Payload (JSON)
Loading...
Defense in depth
- Signature is recomputed server-side on every request and compared byte-for-byte
- The verification library is pinned to an explicit allow-list of algorithms (e.g. only HS256), ignoring the alg the token itself claims
- Short expiry limits the value of any token that does slip through
Vulnerable vs. Fixed
// DO NOT DO THIS
const decoded = jwt.decode(token); // no verification at all
if (decoded.role === "admin") grantAccess();