A comprehensive collection of JWT (JSON Web Token) security vulnerabilities for educational purposes. This project demonstrates various attack vectors and common implementation mistakes in JWT authentication.
Demonstrates how a misconfigured JWT implementation can be exploited using the 'none' algorithm attack.
- Vulnerability: Accepting 'none' as a valid algorithm
- Attack Vector: Algorithm header manipulation
- Impact: Authentication bypass
Shows how weak secrets in JWT signatures can be exploited.
- Vulnerability: Using weak secret keys
- Attack Vector: Brute force attack on signature
- Impact: Token forgery
Explores how the Key ID header parameter can be exploited for directory traversal.
- Vulnerability: Unsanitized file path in KID header
- Attack Vector: Directory traversal via KID parameter
- Impact: Arbitrary file read, token forgery
Demonstrates vulnerabilities in JWK Set URL handling.
- Vulnerability: Unvalidated JKU header
- Attack Vector: Malicious JWK Set hosting
- Impact: Token forgery using attacker-controlled keys
- Node.js (v14 or higher)
- npm
# Clone the repository
git clone [your-repo-url]
# Install dependencies
npm install
# Start the server
node server.jsVisit http://localhost:3001 in your browser
- Regular User
- Username: user
- Password: user
- Admin
- Username: admin
- Password: password
- Login as regular user
- Get the JWT token
- Create a new token with:
eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJ1c2VybmFtZSI6ImFkbWluIiwicm9sZSI6ImFkbWluIn0. - Use the modified token to access admin data
- Login as regular user
- Get the JWT token
- Use hashcat to crack the signature:
hashcat -a 0 -m 16500 "JWT_TOKEN_HERE" wordlist.txt - Create a new token with admin privileges using the cracked secret
- Login as regular user
- Get the JWT token
- Create a new token with modified header pointing to public CSS file
- Sign the token using the CSS file contents
- Use the modified token to access admin data
- Login as regular user
- Get the JWT token
- Create a new token with modified JKU header pointing to malicious JWK Set
- Sign the token using the malicious JWK Set keys
- Use the modified token to access admin data
In a production environment, you should:
- Never accept the 'none' algorithm
- Use strong, randomly generated secrets
- Implement proper signature verification
- Validate and sanitize all header parameters
- Implement proper key management
- Use appropriate access controls
Contributions are welcome! Please feel free to submit pull requests.
This project is for educational purposes only. Use at your own risk.
This project contains intentionally vulnerable code. Do not use any of this code in production environments.
- JWT.io for JWT debugging tools
- Node-JOSE for JWT/JWK functionality
- Express.js team
Created with ❤️ for educational purposes