Cracking JWTs: A Bug Bounty Hunting Guide [Part 6]
The server trusted the JWT 'alg' header and accepted a token signed with HS256 using the server's own public key as the HMAC secret. An attacker could forge an administrator token and access the admin interface to delete a user.
infosecwriteups.com
Published on infosecwriteups.com
Welcome back, Hackers! This is Part 6 of my Cracking JWTs series — your one-stop guide to mastering JWT exploitation techniques in real-world bug bounty hunting.
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
Impact
An attacker could bypass authentication, impersonate an administrator, and delete users without knowing the private key.
What the attacker needed
Access to the lab environment; valid user credentials; Burp Suite with JWT Editor extension
The fix
The server should enforce a strict expected algorithm and never use a public key as an HMAC secret.
How it was found
- Log in to the lab with the provided credentials.
- Try to access /admin and see the admin-only message.
- Send the /admin request to Burp Repeater.
- Fetch the server's public key from the JWKS endpoint.
- Create a symmetric key in JWT Editor using the Base64-encoded public key as the secret.
- Modify the JWT to set alg to HS256 and sub to administrator, sign it with the symmetric key, and send the request.
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 JWT is a signed token that proves who you are. The server checks the signature using a key. Here the server let the attacker choose the checking method and used its own public key as a shared secret, so the attacker could sign a fake admin token.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.