JWT Secret Cracking
Offline recovery of an HMAC (HS256/384/512) signing secret from a captured token, or discovery of a hardcoded/default/leaked secret, so the attacker can mint arbitrary valid tokens.
How it works
An HMAC-signed JWT is self-contained: HMAC-SHA256(base64url(header) + "." + base64url(payload), secret). The verifier and the attacker both hold everything except the secret, so a guessed secret can be tested entirely offline — no requests to the target, no rate limit, no lockout. RFC 7518 requires a key “of the same size as the hash output (256 bits for HS256) or larger”; secrets below that, dictionary words, defaults and placeholders fall quickly.
Offline brute force / dictionary
hashcat -a 0 -m 16500 <jwt> <wordlist> signs each candidate and compares to the captured signature; a match prints <jwt>:<secret>. John the Ripper and jwt_tool do the same. A commodity GPU runs HMAC-SHA256 at >100M guesses/s, so short or low-entropy secrets are recovered in seconds on one workstation. The de-facto wordlist is Wallarm’s jwt.secrets.list. In the lab examples a 48-bit secret (Sn1f) cracked trivially. Once the secret is known, re-sign any header/payload.
Finding the secret without cracking
Often the secret is not strong but simply exposed or default:
- Hardcoded fallback in a client bundle: an HS256 session cookie verified against the
JWT_SECRETenv var’s hardcoded fallback — and that fallback string shipped in the public JS bundle and was the production key. Minting a cookie for any user id, email and staff flag needed no victim and no password. Scanners dismiss a short string next toJWT_SECRETas dev leftover; proof is verifying a live cookie against it. - Default when env var unset: Tensei (CVE-2026-129552) fell back to
'auth-secret-key'; Simple Admin Core shippedjS6VKDtsJf3z1n2VKDtsJf3z1n2inapi/etc/core.yaml, and forgingroleId=001(pre-assigned super-admin) was full compromise. Framework session analogues: Apache Airflow’s Flasktemporary_key(CVE-2020-17526), Racksuper secret. - Hard-coded default in shipped config: BISHENG < 3.0.0 (CVE-2026-130840, CWE-321) used a default
jwt_secretinAuthJwt; forge HS256 foruser_id1 with the admin role asaccess_token_cookie(VulnCheck). Tensei’s fallback is tracked as CWE-1394 (Use of Default Cryptographic Key), CVSS 9.3 (VulnCheck). - Client-side token generation: Trint generated Zendesk-SSO JWTs in browser JS with the Zendesk secret hardcoded (source maps shipped too), letting anyone impersonate any customer.
Stateless-auth tooling
These same weaknesses extend beyond JWT to signed framework cookies (Flask/Flask-Login, Django, Laravel, Rack). CookieMonster (Go) and Flask-Unsign decode, unsign and resign such cookies; CookieMonster generates collision-proof digests (low false positives) and runs inline with scanning pipelines at thousands of req/s, with a -resign option to edit contents in one step.
Notable cases
- siteguarding JS-bundle case study: production HS256 key as a client-bundle fallback; auth bypass and cross-user write on a theme API.
- Simple Admin Core (and OpenDeepWiki CVE-2026-119597, ZKEACMS CVE-2026-111633): hardcoded JWT secret → forged super-admin tokens.
- Tensei ≤ 0.11.5 (CVE-2026-129552): hardcoded fallback signing key when
JWT_SECRETunset. - BISHENG < 3.0.0 (CVE-2026-130840, CVSS 9.3): hard-coded default signing secret → unauthenticated admin over users, workspaces, knowledge bases and workflows.
- Intel/CBSE AI Student Community (2026): HS256 secret
intelcracked offline with rockyou; the payload held onlyemail,role,iat,exp, so the forged token was paired with sequential/dashboard/{ID}brute force after email enumeration (login timing, reset-response diff). Fix: high-entropy key rotation, invalidating all sessions, rate limiting, per-account authz (Intel Inside; Account Takeover). - Engagement secrets cracked in practice:
secret,changeme,jwt-secret,<company>-jwt,0000, and the doc-copiedyour-256-bit-secret(robinx0). - PortSwigger weak-signing-key lab: hashcat-crack the secret, generate a JWK, re-sign for admin.
- Trint (H1): client-side JWT generation leaking the Zendesk shared secret.
Detection and testing
- Capture a signed HS* token and run
hashcat -m 16500/jwt_tool -C -d <wordlist>offline. Try the Wallarm list and app-specific guesses (project name, “secret”, “changeme”). - For unknown stateless cookies, run CookieMonster/Flask-Unsign to detect framework and weak key.
- Hunt the secret directly: search JS bundles and source maps for
JWT_SECRET/HMAC strings; verify a live token against any candidate rather than assuming dead code; check config files and defaults when an env var may be unset. - A weak HMAC secret is only reachable if the server verifies HMAC at all — relevant whenever HS* is accepted (see JWT Algorithm Confusion for the asymmetric-to-HMAC path).
Defenses
- HMAC secrets ≥ 256 bits of real entropy (RFC 7518), generated by a CSPRNG, never derived from a word or ID.
- Size by algorithm: RFC 7518 §3.2 sets the floor in bits of key material, not characters — 32 random bytes for HS256, 48 for HS384, 64 for HS512 (
crypto.randomBytes(32),openssl rand -base64 32,secrets.token_urlsafe(32)). A long memorable passphrase still lacks the entropy (Avada Labs). - Crash at startup when the secret is missing or shorter than the floor, so a bad deploy cannot sign with
undefined; pinalgorithmson verify; use a different secret per environment so a leaked dev key cannot sign production tokens; check startup logs, error reports and CI output for the value (Avada Labs). - Treat a weak secret already in use as exposed: rotate, accept the session invalidation, or run a short dual-secret window if a mass logout is unacceptable (Avada Labs).
- Prefer asymmetric signing (RS/ES/EdDSA) so the verification key is useless for forgery and the private key never sits in verifier config; brute force becomes infeasible.
- No hardcoded fallback secrets: fail closed if the key env var is unset. Keep signing keys server-side only; never mint tokens client-side.
- Rotate secrets periodically and on suspected exposure; store in a secret manager, not source or client bundles.
Tools
- hashcat (
-m 16500), John the Ripper,jwt_tool(-C), c-jwt-cracker, jwt-pwn, CookieMonster, Flask-Unsign.
Related
- JSON Web Tokens
- JWT Algorithm Confusion
- JWT Empty Key Forgery
- JWT Token Lifecycle and Revocation
- Hardcoded Secrets
Sources
- Brute Forcing HS256 is Possible · original
- Cracking JWT Keys - Authentication Lab · original
- Lab: JWT authentication bypass via weak signing key · original
- Insecure JSON Web Tokens (The Hacker Recipes) · original
- brendan-rius/c-jwt-cracker: JWT brute-force cracker in C · original
- Introducing CookieMonster: a tool for breaking stateless authentication · original
- JWT signing key in a JavaScript bundle: case study · original
- Tensei auth bypass via hard-coded JWT secret · original
- Simple Admin Core hardcoded JWT secret admin auth bypass writeup · original
- HackerOne: Trint insecure client-side JWT generation · original
- CVE-2025-45768: PyJWT Information Disclosure Vulnerability · original
- Intel Inside: How a Cracked JWT Key led to Full Account Takeover · original
- JWT algorithm confusion: none, HS256/RS256 mix-ups, and kid injection · original
- BISHENG auth bypass via hard-coded JWT signing secret · original
- Tensei auth bypass via hard-coded JWT secret (VulnCheck) · original
- Your JWT Secret Is Probably Too Weak · original