JWT Algorithm Swap
AdvancedExploit a JWT algorithm confusion vulnerability by swapping RS256 to HS256, using the leaked public key as an HMAC secret to forge an admin token.
Progress:
1
Discover the Public Key2
Forge with Algorithm Confusion3
Block the AttackJWT Token Editor
HEADER
"alg":
"typ": "JWT"
PAYLOAD
"sub": "1234567890"
"name": "Jane Doe"
"role":
"iat": 1716239022
Server — api.example.com
GET/.well-known/jwks.json
ENCODED TOKEN
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkphbmUgRG9lIiwicm9sZSI6InVzZXIiLCJpYXQiOjE3MTYyMzkwMjJ9....