How I Exploited a JWT Misconfiguration for Account Takeover and Admin Access in 5 Minutes
The application accepted HS256 JWTs signed with an empty key, so an attacker could forge tokens with any payload. By changing the user type to Admin and altering the user ID, the author gained admin access and accessed other users' profiles.
Hey there, back again with another post! 😄 In this post I’ll be sharing an interesting finding from an internal web pentest where I discovered an account takeover vulnerability caused by a JWT misconfiguration. In this write-up, I’ll walk you through my approach step by step how I identified the flaw and ultimately…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the server was configured with an empty or missing HS256 signing secret, so it accepted tokens with no valid signature.
Impact
An attacker could forge tokens to impersonate any user, including admins, leading to full account takeover and privilege escalation.
What the attacker needed
Access to a valid JWT token; ability to send modified tokens
How it was found
- Capture the application's JWT token.
- Check the token algorithm with jwt_tool and find it uses HS256.
- Attempt to crack the signing key with hashcat and rockyou.txt.
- Notice no key is found, indicating an empty signing key.
- Use the JWT Editor extension in Burp Suite to create a token with an empty signature and a modified payload.
- Change the user type to Admin and modify the user ID, then use the token to access other users' profiles.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A JSON Web Token (JWT) is a signed piece of data a website gives you after login to prove who you are. The signature is meant to stop people editing the token, but here the signing key was empty, so anyone could make their own token claiming to be an admin or another user.
What is Account takeover?
Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.