JWT Authentication Bypass via Weak Signing Key
The application used a weak JWT signing key that could be brute-forced, allowing an attacker to forge a token with administrator privileges and access the admin panel to delete users.
medium.com
Published on medium.com
This scenario focuses on a JWT-based authentication system that relies on a dangerously weak signing key. Because JSON Web Tokens must be signed with a secret known only to the server, the strength of that secret defines the integrity of every session.
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 application used a weak, guessable secret key to sign JWTs, allowing brute-force recovery of the key.
Impact
An attacker could forge valid tokens for any account, including administrators, bypassing authentication and authorization controls.
What the attacker needed
A free account; ability to intercept HTTP traffic; access to a wordlist of common JWT secrets
The fix
The application should use a strong, randomly generated secret key that is not guessable.
How it was found
- Log in as the standard user wiener.
- Install the JWT Editor extension in Burp Suite and observe the JWT session cookie.
- Attempt to access /admin and confirm access is denied.
- Download a wordlist of common JWT secrets.
- Run Hashcat in mode 16500 with the JWT and wordlist to crack the signing key.
- Use jwt.io to change the sub claim from wiener to administrator, re-sign with the recovered key, and replace the session cookie to access /admin and delete user carlos.
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 like a tamper-proof ID card that the server gives you after login. The server signs it with a secret key so it can tell if someone changed it. Here the secret was easy to guess, so an attacker could make their own ID card claiming to be an administrator.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.