JWT algorithm confusion Vulnerabilities
Background: two different trust models
x
Symmetric (HS256)
Asymmetric (RS256)
Root cause
public_key = get_verification_key() # server's known RSA public key
jwt.decode(token, key=public_key, algorithms=["RS256", "HS256"])The attack, step by step
Why it works - no crypto is broken
How this differs from jwk/jku/kid attacks
x
Attacker supplies...
Fix
One-line summary
Algorithm Confusion Attack, STEPS
Step 1 - Obtain the server's public key
Step 2 - Convert to the format the server uses internally
a) Import the JWK into JWT Editor
b) Get it as PEM
c) Base64-encode this entire PEM string (including the -----BEGIN/END----- lines and line breaks)
d) Create a symmetric key using this as the secret
Step 3 - Modify the JWT
Step 4 - Sign the JWT
Deriving public keys from existing tokens
Last updated