jwt_tool v2.2.1 releases: A toolkit for testing, tweaking and cracking JSON Web Tokens
The JSON Web Token Toolkit
jwt_tool.py is a toolkit for validating, forging and cracking JWTs (JSON Web Tokens).
Its functionality includes:
- Checking the validity of a token
- Testing for the RS/HS256 public key mismatch vulnerability
- Testing for the alg=None signature-bypass vulnerability
- Testing the validity of a secret/key/key file
- Identifying weak keys via a High-speed Dictionary Attack
- Forging new token header and payload values and creating a new signature with the key or via another attack method
This tool is written for pentesters, who need to check the strength of the tokens in use and their susceptibility to known attacks.
It may also be useful for developers who are using JWTs in projects but would like to test for stability and for known vulnerabilities when using forged tokens.
[+] New scan test (re-signing of tokens with common passwords) in ‘Playbook’ scan mode (
[+] Added new hard-coded secret from CVE-2020-1764 to jwt-common.txt
This tool is written natively in Python 2.x using the common libraries.
Customized wordlists are recommended for the Dictionary Attack option.
As a speed reference, an Intel i5 laptop can test ~1,000,000 passwords per second on HMAC-SHA256 signing. YMMV.
git clone https://github.com/ticarpi/jwt_tool.git
(chmod the file too if you want to add it to your $PATH and call it from anywhere.)
$ python jwt_toolkit.py <JWT> (wordlist_file)
The first argument should be the JWT itself, followed by a wordlist filename (if you are trying to crack the token).
$ python jwt_toolkit.py eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJhZG1pbiI6IHRydWUsICJuYW1lIjogInRpY2FycGkifQ.DRkDo/XFb/dJCZXiVOMORxq+gcpA7g50xpwfk3UPrJc rockyou.txt
The toolkit will validate the token and list the header and payload values.
It will then provide a menu of your available options.
- A great intro to JWTs – https://jwt.io/introduction/
- A lot of the inspiration for this tool comes from the vulnerabilities discovered by Tim McLean.
Check out his blog on JWT weaknesses here: https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/
- My introduction to using this toolkit and a bit of the history behind it can be found on my blog – https://www.ticarpi.com/introducing-jwt-tool/
- A couple of exercises for testing JWT vulnerabilities are provided by Pentesterlab. I’d highly recommend a PRO subscription if you are interested in Web App Pentesting.
PLEASE NOTE: This toolkit will solve the Pentesterlab JWT exercises in a few seconds when used correctly, however, I’d strongly encourage you to work through these exercises yourself, working out the structure and the weaknesses. After all, it’s all about learning…