# 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_SECRET` env 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 to `JWT_SECRET` as 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 shipped `jS6VKDtsJf3z1n2VKDtsJf3z1n2` in `api/etc/core.yaml`, and forging `roleId=001` (pre-assigned super-admin) was full compromise. Framework session analogues: Apache Airflow's Flask `temporary_key` (CVE-2020-17526), Rack `super secret`. - **Hard-coded default in shipped config**: BISHENG < 3.0.0 (CVE-2026-130840, CWE-321) used a default `jwt_secret` in `AuthJwt`; forge HS256 for `user_id` 1 with the admin role as `access_token_cookie` ([[raw/vulncheck.com/bisheng-auth-bypass-via-hard-coded-jwt-signing-secret-15965|VulnCheck]]). Tensei's fallback is tracked as CWE-1394 (Use of Default Cryptographic Key), CVSS 9.3 ([[raw/vulncheck.com/tensei-auth-bypass-via-hard-coded-jwt-secret-15964|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_SECRET` unset. - **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 `intel` cracked offline with rockyou; the payload held only `email`, `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 ([[raw/infosecwriteups.com/intel-inside-how-a-cracked-jwt-key-led-to-full-account-takeover-15877|Intel Inside]]; [[Account Takeover]]). - **Engagement secrets** cracked in practice: `secret`, `changeme`, `jwt-secret`, `<company>-jwt`, `0000`, and the doc-copied `your-256-bit-secret` ([[raw/robinx0.github.io/jwt-algorithm-confusion-none-hs256-rs256-mix-ups-and-kid-injection-15974|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. - 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 - [[raw/auth0.com/brute-forcing-hs256-is-possible-4120|Brute Forcing HS256 is Possible]] - [[raw/authlab.digi.ninja/cracking-jwt-keys-authentication-lab-4118|Cracking JWT Keys - Authentication Lab]] - [[raw/portswigger.net/lab-jwt-authentication-bypass-via-weak-signing-key-4125|Lab: JWT authentication bypass via weak signing key]] - [[raw/thehacker.recipes/insecure-json-web-tokens-the-hacker-recipes-4558|Insecure JSON Web Tokens (The Hacker Recipes)]] - [[raw/github.com/brendan-rius-c-jwt-cracker-jwt-brute-force-cracker-in-c-3841|brendan-rius/c-jwt-cracker: JWT brute-force cracker in C]] - [[raw/ian.sh/introducing-cookiemonster-a-tool-for-breaking-stateless-authentication-7031|Introducing CookieMonster: a tool for breaking stateless authentication]] - [[raw/siteguarding.com/jwt-signing-key-in-a-javascript-bundle-case-study-14443|JWT signing key in a JavaScript bundle: case study]] - [[raw/github.com/tensei-auth-bypass-via-hard-coded-jwt-secret-15279|Tensei auth bypass via hard-coded JWT secret]] - [[raw/hackmd.io/simple-admin-core-hardcoded-jwt-secret-admin-auth-bypass-writeup-12868|Simple Admin Core hardcoded JWT secret admin auth bypass writeup]] - [[raw/hackerone.com/hackerone-trint-insecure-client-side-jwt-generation-4106|HackerOne: Trint insecure client-side JWT generation]] - [[raw/sentinelone.com/cve-2025-45768-pyjwt-information-disclosure-vulnerability-4722|CVE-2025-45768: PyJWT Information Disclosure Vulnerability]] - [[raw/infosecwriteups.com/intel-inside-how-a-cracked-jwt-key-led-to-full-account-takeover-15877|Intel Inside: How a Cracked JWT Key led to Full Account Takeover]] - [[raw/robinx0.github.io/jwt-algorithm-confusion-none-hs256-rs256-mix-ups-and-kid-injection-15974|JWT algorithm confusion: none, HS256/RS256 mix-ups, and kid injection]] - [[raw/vulncheck.com/bisheng-auth-bypass-via-hard-coded-jwt-signing-secret-15965|BISHENG auth bypass via hard-coded JWT signing secret]] - [[raw/vulncheck.com/tensei-auth-bypass-via-hard-coded-jwt-secret-15964|Tensei auth bypass via hard-coded JWT secret (VulnCheck)]]