JWTHunter is a powerful JWT (JSON Web Token) testing tool designed for security researchers and bug bounty hunters to identify and exploit common JWT vulnerabilities.
JSON Web Tokens (JWTs) are widely used for authentication and session management in modern web applications. Unfortunately, many JWT implementations contain vulnerabilities that can lead to authentication bypasses and privilege escalation. JWTHunter helps security researchers identify and demonstrate these vulnerabilities in a controlled environment.
-
Multiple Exploitation Methods:
jwk
header injection (embeds forged key material directly in the token)jku
header injection (points verification to an attacker-controlled URL)
-
Customizable Payloads:
- Modify claims to test privilege escalation
- Change user roles and permissions
- Test authorization boundaries
-
PortSwigger Lab Compatible:
- Specially optimized for PortSwigger Web Security Academy labs
- Detailed step-by-step instructions for solving lab challenges
-
Comprehensive Output:
- Debug information for original and modified tokens
- Generated JWK and JWK Sets
- Example curl commands for testing
# Clone the repository
git clone https://github.com/yourusername/jwthunter.git
cd jwthunter
# Install requirements
pip install -r requirements.txt
- Python 3.6+
- cryptography
python jwthunter.py --jwt "eyJhbGciOiJSUzI..." --method jwk
python jwthunter.py --jwt "eyJhbGciOiJSUzI..." --method jku --jku-url "https://your-server.com/jwks.json"
python jwthunter.py --jwt "eyJhbGciOiJSUzI..." --method jwk --payload '{"sub":"admin","role":"admin"}'
python jwthunter.py --jwt "eyJhbGciOiJSUzI..." --method jku --jku-url "https://exploit-server.net/exploit.json" --portswigger
- Get a valid JWT from the lab application
- Run JWTHunter with the jku method:
python jwthunter.py --jwt "your_token" --method jku --jku-url "https://your-exploit-server.net/exploit.json" --portswigger
- Copy the JWK Set JSON to your Exploit Server
- Set the filename to
exploit.json
- Make sure Content-Type is set to
application/json
- Store and view the exploit to verify it works
- Use the modified token to access admin resources
- Get a valid JWT from the lab application
- Run JWTHunter with the jwk method:
python jwthunter.py --jwt "your_token" --method jwk --portswigger
- Use the generated token to access admin resources
- Algorithm confusion attack (
alg: none
and RS256/HS256 confusion) - Key ID (kid) parameter injection attacks
- JWT signature validation bypass via x5c header injection
- Support for cracking weak JWT secrets
This tool is provided for educational and professional security testing purposes only. Use it only on applications you own or have explicit permission to test. Unauthorized testing of systems is illegal and unethical.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by vulnerabilities documented by PortSwigger Web Security Academy
- Created for security professionals conducting authorized bug bounty testing