Skip to content
fecailabsPublic

About

Dependency-free JWT attack toolkit: decode and audit, alg:none and algorithm-confusion forgery, HMAC secret cracking and claim tampering.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

forge

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.

Features

  • Decode and audit a token: pretty-printed header, payload and signature, plus findings for alg:none, embedded jwk, jku/x5u key sources, kid injection 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.

Install

gem install forge

Or run from source:

git clone https://github.com/fecailabs/forge
cd forge
ruby bin/forge <token>

Usage

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.pem

Crack a weak secret:

forge crack <token> -w wordlist.txt

Tamper a claim and re-sign with a known secret:

forge tamper <token> -set role=admin -secret s3cr3t

Sign a fresh token:

forge sign -set sub=1 -set role=admin -secret s3cr3t -alg HS256

Commands

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

Options

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

Scope

forge is for authorised security testing and research. Only test systems you own or are explicitly permitted to assess.

License

MIT, see LICENSE.

About

Dependency-free JWT attack toolkit: decode and audit, alg:none and algorithm-confusion forgery, HMAC secret cracking and claim tampering.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages