JWT Claim Manipulation
What You'll Learn
You'll discover how attackers can modify JWT payload claims to escalate privileges or bypass security controls, even when the signature is not properly validated.
The Vulnerability
Even if you've protected against signature vulnerabilities (like the 'none' algorithm and algorithm confusion), the payload itself can be a weakness. JWT claims contain critical data—user IDs, roles, permissions, expiration timestamps—and if an application doesn't properly validate these claims after decoding, attackers can modify them to gain unauthorized access.
Think of it like a concert ticket: the signature proves it's authentic, but if the venue doesn't check whether the ticket says "VIP" or "General Admission," someone could write in "Backstage Pass" and walk right in.
Common Claim Manipulation Attacks
User Impersonation
Changing the sub (subject) or user_id claim to masquerade as another user:
{
"sub": "12345", // Changed from attacker's ID
"role": "user"
}
Privilege Escalation
Modifying role or permission claims:
{
"sub": "attacker",
"role": "admin", // Changed from "user"
"permissions": ["read", "write", "delete"]
}
Expiration Bypass
Extending the exp (expiration) claim to keep tokens valid indefinitely:
{
"sub": "user123",
"exp": 9999999999 // Far future timestamp
}
Why This Works
Applications sometimes decode JWTs and immediately trust the claims without:
- Validating the signature first
- Checking claims against server-side data
- Enforcing claim value constraints
- Verifying critical claims haven't been tampered with
Key Takeaway: Always validate JWT signatures before trusting claims, verify critical claims against authoritative sources, and implement server-side authorization checks—never rely solely on JWT claim values for security decisions.