A dependency-free JSON Web Token attack toolkit. forge decodes and audits tokens, generates alg:none and algorithm-confusion forgeries, cracks weak HMAC secrets, and re-signs tampered claims — using only the Ruby standard library.
- Decode and audit a token: pretty-printed header, payload and signature, plus findings
for alg:none, embedded
jwk,jku/x5ukey sources,kidinjection surface, missing expiry and expired tokens. - alg:none forgeries in four casing variants (
none,None,NONE,nOnE), each in stripped and no-trailing-dot form, plus a null-signature forgery that keeps the original algorithm with an empty signature. - Algorithm confusion (RS256 to HS256): re-sign with HMAC using the server's RSA public key, emitting multiple key serialisations (SPKI, trailing-newline toggles, CRLF, DER) to satisfy the byte-for-byte key-match requirement.
- jwk header injection (CVE-2018-0114): embed a generated public key in the header and sign with its private key.
- jku header injection: forge the token and print the attacker JWKS to host.
- kid manipulation: path traversal (sign with an empty key against
/dev/null) and injection payloads. - Secret cracking for HS256/384/512 against a wordlist or a built-in common-secrets list (run automatically when no wordlist is given), with constant-time comparison.
- Tamper and sign: modify claims and re-sign with a known or blank secret, or build a token from scratch.
- Human-readable and JSON output.
- No runtime gem dependencies.
gem install forgeOr run from source:
git clone https://github.com/fecailabs/forge
cd forge
ruby bin/forge <token>Decode and audit a token:
forge eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.____Generate alg:none forgeries:
forge none <token>Algorithm confusion with a captured public key:
forge confusion <token> -pub public.pemCrack a weak secret:
forge crack <token> -w wordlist.txtTamper a claim and re-sign with a known secret:
forge tamper <token> -set role=admin -secret s3cr3tSign a fresh token:
forge sign -set sub=1 -set role=admin -secret s3cr3t -alg HS256| Command | Description |
|---|---|
analyze (default) |
Decode and audit a token |
decode |
Alias for analyze |
none |
Emit alg:none forgeries (stripped and no-dot) |
nullsig |
Strip the signature while keeping the algorithm |
confusion |
RS256-to-HS256 forgery across key forms, needs -pub |
jwk |
Embed a generated key in the header (CVE-2018-0114) |
jku |
Forge with an attacker jku and print the JWKS, needs -jku |
x5c |
Embed a self-signed certificate in the header (CVE-2018-0114 variant) |
kid |
kid path traversal (-file) or injection (-sqli) |
crack |
Recover a weak HMAC secret (-w, else built-in list) |
tamper |
Change claims and re-sign |
sign |
Build and sign a token |
| Flag | Description |
|---|---|
-set k=v |
Set a claim (repeatable); values are parsed as JSON when possible |
-secret |
HMAC secret for signing |
-alg |
Signing algorithm (default HS256) |
-pub |
Public key PEM for algorithm confusion |
-w |
Wordlist file for cracking |
-none |
Produce an unsigned token when tampering |
-json |
Write results as JSON |
-nc |
Disable coloured output |
-q |
Suppress the banner |
-version |
Print the version and exit |
forge is for authorised security testing and research. Only test systems you own or are explicitly permitted to assess.
MIT, see LICENSE.