Cracking JWTs: A Bug Bounty Hunting Guide [Part 7] — The Final P1 Boss
The server accepted HS256-signed JWTs even though it was configured for RS256, and it used the RSA public key as the HMAC secret. An attacker could forge an admin token without the private key and delete a user.
infosecwriteups.com
Published on infosecwriteups.com
After days of intense lab break-ins, PoC crafting, and diving headfirst into JWT madness — we’ve arrived. This is the final chapter in my “Cracking JWTs: A Bug Bounty Hunter’s Guide” series.
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 gain admin access and delete user accounts.
What the attacker needed
A free account; ability to capture two JWTs; Burp Suite with JWT Editor; Docker for sig2n
The fix
The server should enforce the expected algorithm and never accept HS256 when configured for RS256, and should not use the 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.
- Log out and log in again to capture two session JWTs.
- Run the sig2n tool with the two JWTs to derive possible public keys and tampered tokens.
- Test each tampered JWT in the session cookie until one returns 200 OK on /my-account.
- Create a symmetric key in JWT Editor using the valid public key, change the sub claim to administrator, set alg to HS256, sign, and send to /admin.
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.
JWTs are signed tokens that prove who you are. Normally the server checks the signature with a secret or public key. Here the server was tricked into checking with the wrong method, so an attacker could make a fake admin token without knowing the real secret.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.