JWT Brute-forcing secret keys (weak signing key)
PreviousJWT Accepting Unsigned Tokens (alg: none)NextJWT header parameter injections (jwk injection)
Last updated
What it is: HS256 uses a plain string as the secret key. If it's weak, default, or copy-pasted from example code/docs, an attacker can brute-force it offline.
Why it works: Anyone with the secret can generate valid signatures for any payload they want - no server interaction needed, since signing is just a local math operation.
How to exploit:
Grab a valid JWT from the target.
Run it against a wordlist of common/known secrets:
hashcat -a 0 -m 16500 <jwt> <wordlist>Hashcat re-signs the header+payload with each wordlist entry and checks for a match against the token's signature.
Match found → secret recovered → forge any token (e.g. sub: administrator) and sign it yourself.
Note: Runs fully offline/locally, so it's fast even with large wordlists.
Fix: Use a long, random, high-entropy secret - never a default, placeholder, or dictionary word. Rotate secrets if ever suspected leaked.
Lab 3 JWT authentication bypass via weak signing keyLast updated