JWack is a powerful security tool designed for interacting with JSON Web Tokens (JWT). It allows users to decode JWTs, perform brute-force attacks on secrets, test for vulnerabilities like alg:none, modify JWT payloads, sign tokens with custom RSA keys and JWK headers, and test injection attacks on the jku. The tool is designed to assist security researchers, penetration testers, and developers in evaluating the security of JWT implementations in web applications.
- JWT Decode: Decodes the JWT header, payload, and signature for analysis.
- JWT Secret Bruteforce: Brute forces the secret used to sign the JWT using a wordlist.
- alg Attack: Exploits weak JWT implementations where the alg field can be tampered with.
- Parameter Editing: Modify or add parameters to the JWT header and payload.
- Unverified Signature Bypass: Test the system’s vulnerability to unsigned JWTs by creating a new token with altered claims while keeping the signature intact.
- JWK (JSON Web Key) Support: Generate an RSA key pair, convert the public key into JWK format, and sign the JWT with the RSA private key.
- JKU Parameter Injection: Exploit potential vulnerabilities in JWT implementations by injecting malicious values into the JKU parameters.
The tool can be run from the command line using various options and flags. Below is a detailed guide on each command.
-f, --file <path> Path to the wordlist for brute-force attack.
-t, --token <JWT> JWT to decode, edit, or sign.
-d, --decode Decode the JWT token.
-bf, --bruteforce Brute-force the JWT secret.
-n, --none Perform alg:none attack.
-e, --edit Edit header or payload values.
-us, --unverified Generate token with altered values using the same signature (Unverified Signature Bypass).
-jwk, --jwk Generate a JWK key and sign the JWT.
-jku, --jku Perform JKU header injection.
python jwack.py -t <JWT> --decode
This will output the decoded header and payload of the JWT.
python jwack.py -t <JWT> -f <wordlist> --bruteforce
This will try each secret in the provided wordlist to match the JWT signature.
python jwack.py -t <JWT> --none
This exploits the vulnerable alg
parameter by changing it to none
and removing the signature.
python jwack.py -t <JWT> --edit
The tool will prompt you to edit or add new parameters to the header or payload.
python jwack.py -t <JWT> --unverified
This will modify the JWT claims but retain the original signature to test if the system verifies signatures properly.
python jwack.py -t <JWT> --jwk
This generates an RSA key pair, converts the public key to a JWK, and signs the token with the RSA private key.
This feature will allow users to inject a malicious URL in the jku
header, which could be used to retrieve a malicious key set.
python jwack.py -t <JWT> --jku
- Purpose: Decodes the JWT and returns its header, payload, and signature.
- Parameters:
token
- The JWT string. - Returns: Decoded header and payload.
- Purpose: Performs a brute-force attack on the JWT signature using a wordlist of candidate secrets.
- Parameters:
file_path
- Path to the wordlist.token
- The JWT to be brute-forced.
- Returns: The secret used to sign the JWT if found.
- Purpose: Exploits JWTs that allow changing the algorithm to
none
. - Parameters:
token
- The JWT string. - Returns: Modified JWT with the
none
algorithm and no signature.
- Purpose: Allows the user to interactively edit or add parameters to the JWT's header or payload.
- Parameters:
token
- The JWT string. - Returns: Modified JWT.
- Purpose: Generates an RSA key pair and outputs the public key in JWK format.
- Parameters:
token
- The JWT string (used to extract thekid
if present). - Returns: JWK and private RSA key.
- Purpose:
Signs the JWT with the generated RSA private key using the JWK header format.
- Parameters:
token
- The JWT string to be signed. - Returns: Signed JWT with JWK and RSA private key.
- Purpose: Alters the JWT payload and retains the same signature to test systems that don't properly verify signatures.
- Parameters:
token
- The JWT string. - Returns: JWT with modified claims and the original signature intact.
- Purpose: Injects a custom URL into the
jku
field to point to an external key set. - Parameters:
token
- The JWT string. - Returns: JWT with the malicious
jku
value.
JWack is a versatile tool aimed at security professionals and developers who need to test the robustness of JWT implementations. With upcoming features like JKU, it will become even more comprehensive. Use this tool responsibly in your security assessments to uncover vulnerabilities in JWT authentication and authorization mechanisms.