EncryptCodecencryptcodec
Simulations/JWT Algorithm Swap

JWT Algorithm Swap

Advanced

Exploit 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 Key
2
Forge with Algorithm Confusion
3
Block the Attack
JWT 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....

Challenges

1
Discover the Public Key
Fetch the server's public key from the JWKS endpoint.
hints
2
Forge with Algorithm Confusion
Change the algorithm from RS256 to HS256 and forge an admin token.
hints
3
Block the Attack
Configure the server to reject the algorithm confusion attack.
hints
How to fix JWT algorithm confusion
Whitelist algorithms and validate key types

Frequently Asked Questions