Guide

JWT Security Testing

The JWT tab is a workbench for JSON Web Tokens: decode one, edit its claims and re-sign it, and generate the classic attack payloads to test against the server. The Decoder's read-only jwt-decode converter only shows the parts.

gori JWT tab with a decoded HS256 token: the INPUT token under a →ENCODE lens chip, the decoded header JSON, and an ATTACKS list of 23 generated payloads including alg=none case variants and signature stripping
The JWT tab decodes a token live (header, payload, signature) and lists ready-to-send attack payloads: alg:none, weak-secret, and header injection.

Select a token anywhere (a History detail pane, Notes, …) and Space S (Send selection to…) → j JWT to seed a new workbench sub-tab with it. Sessions are ephemeral, and nothing is written to disk. The tab is off the bar by default. Press 0 and type "jwt", use the command palette (Ctrl-P → Go to JWT), or give it a slot in Preferences.

Two Lenses

A session has two views, toggled with Ctrl-T. The top card of each lens carries the switch on its border (→ENCODE on INPUT, →DECODE on HEADER), and clicking it also toggles:

  • Decode: paste a token into INPUT and the header, payload, and signature decode live. Below them is a selectable list of generated attack payloads.
  • Encode: edit the HEADER and PAYLOAD as JSON, choose an algorithm (Ctrl-A cycles the HMAC family, then RS/PS/ES at 256/384/512, EdDSA, and none), set a SECRET, and the re-signed token appears live in OUTPUT. For an asymmetric algorithm the card becomes KEY and takes a path to a PEM private key instead of a typed secret.

Space → Load decoded claims loads the token currently decoded on the Decode side into the Encode editors, ready to edit a claim and re-sign. Copy any result with y.

A signature is decoded and shown but never verified on the Decode side, so a decode tells you what a token claims, not whether it is trusted. Encode signs with the key and algorithm you give it, and gori run jwt --verify (or MCP jwt_verify) verifies the signature when you hold the key.

Algorithms

HMAC (HS256 / HS384 / HS512) signs with a secret you type. The asymmetric families sign with a PEM key you supply. gori does not generate keys, so forging an RS256 token still requires the RS256 private key:

Family Algorithms Key
HMAC HS256 HS384 HS512 the shared secret, inline
RSA PKCS#1 RS256 RS384 RS512 an RSA private key to sign, public key / certificate to verify
RSA-PSS PS256 PS384 PS512 the same RSA key; salt length is the digest length (RFC 7518 §3.5)
ECDSA ES256 ES384 ES512 a P-256 / P-384 / P-521 key. The signature is the fixed-width r‖s form JOSE mandates, so ES512 is 132 bytes, not 128
EdDSA EdDSA an Ed25519 key
Unsigned none none: the auth-bypass shape

A key is either inline PEM text or a path to a .pem file. A file that holds no PEM block is refused as <file> is not a PEM key. An HMAC secret kept in a file belongs in --secret, not --key. Verification additionally accepts an X.509 certificate (what an IdP publishes as x5c) or the private key itself.

Encrypted Tokens (JWE)

A five-part header.encrypted_key.iv.ciphertext.tag token is a JWE, an encrypted JWT. gori recognizes it everywhere it recognizes a JWS (the JWT tab, the Decoder, the body pretty-printer, gori run jwt, MCP jwt_decode) and shows the protected header: the alg that wrapped the content-encryption key, the enc that encrypted the claims, and the kid.

gori does not decrypt. The claims are marked encrypted and nothing is guessed in their place. Tools that work on claims refuse the token: --attacks generates nothing (there is no claims segment to tamper with and no signature to strip), and --verify says the token is encrypted instead of reporting an unsupported algorithm.

Attack Payloads

From a decoded token, gori generates ready-to-send variants that probe common JWT verification flaws:

Attack What it tests
alg:none Strips the signature and sets alg to none (plus the None / NONE / nOnE case variants), for a server that accepts unsigned tokens. Two more payloads keep the original header: signature stripped (an empty third segment) and no signature segment (a 2-part token).
Weak secret Re-signs the token with a list of common weak HMAC secrets, to catch a guessable signing key.
Header injection Manipulates the kid, jku, x5u, and jwk header parameters, for a server that trusts attacker-supplied key material.
Algorithm confusion Only with the server's public key (--attacks --key, MCP public_key). Downgrades an RS/PS/ES token to HS256 and HMAC-signs it with the public key's own bytes, for a server that dispatches on the token's alg and reuses its verification key. One payload per spelling a server might hold: the canonical SPKI PEM OpenSSL would write, and the bytes as supplied with and without a trailing newline.

Copy the highlighted payload with y and paste it into a Repeater session (or a request you're already editing) to try it against the target.

Crack an HMAC secret

For an HS256, HS384 or HS512 token, search your own candidates offline from the CLI or MCP:

gori run jwt "$TOKEN" --crack --secrets 'first,second' --wordlist secrets.txt --json

Inline candidates run first, followed by the newline-delimited file. --wordlist also accepts a saved wordlist name: the current directory wins, then the global catalog is searched. Empty lines are empty-secret candidates; spaces are preserved. The result carries found, secret on a hit, and tried. The CLI exits 0 on a hit and 1 on a miss or refusal. none, asymmetric tokens, malformed signatures and encrypted JWEs are refused before searching. Nothing is sent to the target.

MCP jwt_crack takes token, secrets (an array) and/or wordlist (a file path or saved name). Client cancellation stops the search between candidates and frees the server for the next call; like every cancelled request, it gets no response. It is available with the full catalogue and under --read-only, outside @recon. The JWT tab keeps its current layout; wordlist cracking is available through these headless surfaces.

Headless

gori run jwt eyJhbGci...                       # decode (default)
gori run jwt eyJhbGci... --encode --alg HS256 --secret s3cret
gori run jwt eyJhbGci... --encode --set role=admin --secret s3cret   # patch one claim, re-sign
gori run jwt eyJhbGci... --encode --payload '{"sub":"1","admin":true}' --secret s3cret   # replace the claims wholesale
gori run jwt eyJhbGci... --encode --set-header kid=../../dev/null --secret ''   # inject a header field, re-sign
gori run jwt --encode --header '{"jku":"https://evil"}' --payload '{"sub":"admin"}' --secret s3cret   # mint, no token
gori run jwt eyJhbGci... --encode --alg ES256 --key ./private.pem     # sign with an asymmetric key
gori run jwt eyJhbGci... --verify --key ./public.pem                  # does this token check out?
gori run jwt eyJhbGci... --attacks             # print the attack payloads
gori run jwt eyJhbGci... --attacks --key ./public.pem                 # ...plus algorithm confusion
cat token.txt | gori run jwt --attacks         # token from stdin

The token comes from the argument or stdin. No project or capture is involved, and everything is computed locally. --format is text or json. On --encode, --set KEY=VALUE patches one claim (repeatable, and the value is JSON when it parses, so admin=true is a boolean and role=admin a string) and --payload JSON replaces the claims object. The two are mutually exclusive. --set-header FIELD=VALUE and --header JSON do the same to the header, where a kid / jku / jwk header-injection payload is built. alg always comes from --alg. Given both --header and --payload, --encode mints a fresh token and reads none. Given only one, the other half still comes from the token (pass "" or </dev/null to start it from {}). --secret and --key fill the same slot, so pass one. --verify needs --secret or --key (pass --secret '' to check the empty secret), prints verified: yes|no with a reason on a no, and exits 1 unless the token verifies, as gori run cookie --verify does. With --format json a no also carries a code. After signature_mismatch or key_mismatch (a key of the wrong type for the token's alg) another key might succeed. unsigned, alg_unsupported, signature_malformed, jwe and the rest mean no key will. Passing both --secret and --key is refused, --secret '' included. See the CLI Reference.

Over MCP, jwt_decode / jwt_verify / jwt_encode / jwt_attacks are read tools available even under --read-only, since they touch no network and write nothing. jwt_encode takes the same header, set / payload edits and mints with no token when header or payload is given; its private key must be an inline PEM, so the tool never signs with a host file named by the client. jwt_verify's key and jwt_attacks' public_key accept an inline PEM or a path because those operations do not mint a token.

Next Steps

  • Decoder: decode a JWT inside a longer transform chain
  • Sequencer: grade the randomness of a token that is not a JWT
  • Repeater & Fuzzer: send an attack payload to the target