JWT labs
JSON Web Token (JWT) Attacks
What is JWT?
JSON Web Token attacks exploit insecure signature and verification implementations. From accepting alg=none to RS256→HS256 algorithm confusion, weak secrets and kid injection: any of them lets you forge tokens and impersonate any user, admin included.
Why practice JWT?
JWT is the de facto standard for sessions in modern APIs and SPAs, and devs keep tripping over the same signature flaws. A forgeable JWT is direct account takeover of any account, admin included: immediate P1 with $2,000-$30,000 bounties.
What will you learn with the JWT labs?
You'll learn to audit the header and payload, force alg=none, run key confusion by signing with the public key as the HMAC secret, crack weak HS256 secrets with hashcat, and inject the kid/jku/x5u field so the server validates with a key you control.
Types of JWT we cover
- alg=none
You change the header to {"alg":"none"} and remove the signature. Misconfigured libraries accept the token without verifying it.
- Algorithm confusion (RS256→HS256)
The server expects RS256 (asymmetric) but accepts HS256. You sign the token with the (known) public key as the HMAC secret.
- Weak HS256 secret
If the secret is short/common, you crack it offline with hashcat and sign arbitrary tokens, elevating your role to admin.
- kid / jku / x5u injection
The kid/jku/x5u header indicates where to pull the key from. You inject a path, SQL or a URL of yours to control the verification key.
How do you find and exploit JWT?
A practical playbook — from recon to proof of concept.
- 1
Decode the token
Split the three segments and base64url-decode the header and payload. Check the algorithm, the kid field and claims like role or user_id.
echo $JWT | cut -d. -f1 | base64 -d → {"alg":"RS256","kid":"1"} - 2
Try alg=none
Change the algorithm to none, edit the payload (e.g. role=admin) and send the token with no signature. Vulnerable libraries accept it.
header {"alg":"none","typ":"JWT"} · payload {"user":"admin"} · empty signature: header.payload. - 3
Algorithm confusion RS256→HS256
If you know the RSA public key, sign an HS256 token using it as the HMAC secret. A server that verifies with the public key deems it valid.
jwt_tool $JWT -X k -pk public.pem (confusion attack) - 4
Crack weak HS256 secrets
Dump the JWT to hashcat and try a wordlist. A cracked secret lets you sign any token.
hashcat -a 0 -m 16500 jwt.txt rockyou.txt - 5
Inject kid/jku
Tamper kid to point at a known key file (/dev/null → empty secret) or jku/x5u to a JWKS you host.
{"alg":"HS256","kid":"../../../../dev/null"} → sign with an empty secret
Learn the theory
Academy: Authentication Bypass
Loading labs...
View in full catalog →Frequently asked questions
What is a JWT attack?
It's the exploitation of flaws in a JSON Web Token's signature or verification. If the server doesn't validate the signature correctly (alg=none, algorithm confusion, weak secret, kid injection), an attacker can forge tokens and impersonate any user.
How is an insecure JWT exploited?
You decode the token, alter the payload (for example role=admin) and get the server to accept the signature: setting alg=none, signing with the public key as the HMAC secret (RS256→HS256), cracking a weak secret, or injecting kid/jku toward a controlled key.
How do you find JWT flaws in bug bounty?
Decode every token, look at the header (alg, kid, jku) and try alg=none, algorithm confusion and a secret crack with hashcat. Tools like jwt_tool automate sweeping these techniques against the endpoint.
How do you prevent JWT attacks?
Pin the allowed algorithm on the server (don't read alg from the token), use long random secrets or well-managed asymmetric keys, strictly validate kid/jku against an allowlist, and consider opaque tokens with a server-side session for sensitive data.
Difference between a JWT attack and a generic Authentication Bypass?
A JWT attack is a specific sub-category of Authentication Bypass focused on token signatures. Authentication Bypass is the umbrella that also includes password reset poisoning, OAuth flaws or MFA bypass.
Other related categories
- hunters training
- 650
- labs from real reports
- 50
- completions
- 380
- in bounties practiced
- $200,000
hunters training
labs from real reports
completions
in bounties practiced
Practice JWT in real labs
Every JWT lab replicates a real bug bounty report that got paid. Create your free account, start with the Academy and move to the labs whenever you want.
No card · free Academy · cancel anytime