Overview
Comprehensive JWT attack checklist for offensive security engagements. Follow steps in order; apply each technique to the current target context and track which items have been completed.
Quick Reference: Misconfigurations to Check
- Algorithm set to
none — signature verification bypassed entirely
- Algorithm switching between
RSA and HMAC (confusion attack)
- Weak or guessable HMAC secret (brute-forceable)
kid, jku, jwk, x5u header parameters accepted without validation
- Expired or tampered tokens accepted by server
- Sensitive data stored unencrypted in payload
Useful tool: JWT Tool
Mechanisms
JWTs (RFC 7519) consist of three Base64URL-encoded parts: header.payload.signature.
Signing algorithms:
| Algorithm |
Type |
Notes |
| HS256/384/512 |
Symmetric HMAC |
Shared secret; confusion target |
| RS256/384/512 |
Asymmetric RSA |
Public key can be misused as HMAC secret |
| ES256/384/512 |
Asymmetric ECDSA |
|
| PS256/384/512 |
RSASSA-PSS |
|
| EdDSA (Ed25519/Ed448) |
Asymmetric |
|
| none |
Unsigned |
Critically insecure |
Additional pitfalls:
- JWS/JWE confusion: server accepts encrypted token (JWE) where signed (JWS) is expected, or fails open on unexpected
typ/cty
- JWKS retrieval: SSRF via
jku/x5u, insecure TLS, poisoned key caching, kid collisions
- Token binding (DPoP, mTLS): incorrectly implemented allows replay from other clients
Hunt: Identifying JWT Usage
- Check
Authorization: Bearer <token> headers in all requests
- Look for cookies containing JWT structures (
eyJ...)
- Examine browser local/session storage
- Decode the token at jwt.io or via BurpSuite JWT extension — inspect claims and header parameters
- Note any
kid, jku, jwk, x5u fields in the header — these are attack surfaces
Vulnerability Map
JWT Vulnerabilities
├── Algorithm Bypass
│ ├── alg:none attack
│ └── RS256→HS256 confusion (public key as HMAC secret)
├── Weak Secret Key → Brute force
├── kid Parameter Injection
│ ├── SQL injection via kid
│ └── Path traversal via kid
├── Header Injection
│ ├── jwk (inline fake key)
│ ├── jku/x5u (remote attacker-controlled JWKS)
│ └── JWKS cache poisoning
└── Missing / Broken Validation
├── No signature check
├── Expired tokens accepted
└── iss/aud/exp not validated
Vulnerabilities
Algorithm Vulnerabilities
- alg:none — Some libraries disable signature validation when
alg is none or a case variant (None, NONE, nOnE)
- Algorithm Confusion (RS256→HS256) — Server uses RSA public key as HMAC secret when attacker switches
alg to HS256; attacker re-signs token with the public key
- Key ID (
kid) Manipulation — Exploiting kid to load wrong keys or inject file paths / SQL; enforce strict lookups
Signature Vulnerabilities
- Weak HMAC Secrets — Brute-forceable with dictionary or hashcat
- Missing Signature Validation — Token accepted without any verification
- Broken Validation — Implementation errors in signature checking logic
Implementation Issues
- Missing Claims Validation —
exp, nbf, aud, iss not verified
- Insufficient Entropy — Predictable JWT IDs or tokens
- No Expiration — Tokens valid indefinitely
- Insecure Transport — Token sent over HTTP
- Debug Leakage — Detailed error messages expose implementation
Header Injection Attacks
- JWK Injection — Supply a custom attacker-controlled public key via the
jwk header
- JKU Manipulation — Point
jku (JWK Set URL) to attacker-controlled JWKS endpoint
- x5u Misuse — Load untrusted X.509 key URL; exploit lax TLS validation or open redirects
- JWKS Cache Poisoning — Force caches to accept attacker keys via
kid collisions or response header manipulation
crit Header Abuse — Server ignores unknown critical parameters, enabling bypass
Information Disclosure
- Sensitive data (PII, credentials, session details) stored unencrypted in payload
- Internal service/backend information leaked via claims
Additional Attack Vectors
Mobile App JWT Storage
Android:
SharedPreferences: Check if world-readable; location /data/data/<package>/shared_prefs/
- Keystore extraction: root device or exploit app
- Backup extraction:
adb backup -f backup.ab <package> (if allowBackup=true)
- Tools: Frida, objection, MobSF
iOS:
- Keychain: Check
kSecAttrAccessible — kSecAttrAccessibleAlways is insecure
- iTunes/iCloud backup extraction: unencrypted backups expose Keychain
- Jailbreak + Keychain-Dumper for full extraction
- Tools: Frida, objection, idb
React Native / Hybrid:
AsyncStorage stored in plain text (Android SQLite DB, iOS plist); no encryption by default
# Android — check SharedPreferences
adb shell "run-as com.target.app cat /data/data/com.target.app/shared_prefs/auth.xml"
# iOS — extract from backup
idevicebackup2 backup --full /path/to/backup
# Use plist/sqlite tools to extract JWT
JWT Confusion Attacks
- SAML-JWT Confusion — App accepts both SAML and JWT; send JWT where SAML expected or vice versa to exploit weaker validation path
- API Key-JWT Confusion — Test sending JWT where API key expected and vice versa
- Session Cookie-JWT Hybrid — Test expired JWT with valid session cookie; inject JWT claims into session
- OAuth Token Confusion — Send ID token (JWT) to resource server expecting opaque access token
# Try API key where JWT expected
curl -H "Authorization: Bearer <api_key>" https://api.target/resource
# Try JWT where API key expected
curl -H "X-API-Key: <jwt_token>" https://api.target/resource
📎 Detailed content (full examples / references / data tables) has been split into reference.md in the same directory; use Read to load the relevant section on demand.
1---2name: offensive-jwt3description: "JWT attacks: alg:none and RS256->HS256 confusion, HMAC weak-key brute force, kid injection (SQLi/path traversal), jku/x5u header injection, JWKS cache poisoning, timestamp/claim abuse. Signals: jwt, algorithm confusion."4zh-signals: "JWT 攻击:alg:none 与 RS256→HS256 算法混淆、HMAC 弱密钥爆破、kid 注入(SQLi/路径穿越)、jku/x5u 头注入、JWKS 缓存投毒、时信号:jwt,算法混淆。"5when-to-use: >-6 JWT attack methodology for penetration testers. Covers algorithm confusion (alg:none, RS256→HS256), weak HMAC secret brute force, kid parameter injection (SQLi, path traversal), jku/x5u/jwk header in7metadata:8 source: https://skillmd.com/skills/dangeroussong/offensive-jwt9---1011## Overview1213Comprehensive JWT attack checklist for offensive security engagements. Follow steps in order; apply each technique to the current target context and track which items have been completed.1415## Quick Reference: Misconfigurations to Check1617- Algorithm set to `none` — signature verification bypassed entirely18- Algorithm switching between `RSA` and `HMAC` (confusion attack)19- Weak or guessable HMAC secret (brute-forceable)20- `kid`, `jku`, `jwk`, `x5u` header parameters accepted without validation21- Expired or tampered tokens accepted by server22- Sensitive data stored unencrypted in payload2324Useful tool: [JWT Tool](https://github.com/ticarpi/jwt_tool)2526## Mechanisms2728JWTs (RFC 7519) consist of three Base64URL-encoded parts: `header.payload.signature`.2930**Signing algorithms:**3132| Algorithm | Type | Notes |33|-----------|------|-------|34| HS256/384/512 | Symmetric HMAC | Shared secret; confusion target |35| RS256/384/512 | Asymmetric RSA | Public key can be misused as HMAC secret |36| ES256/384/512 | Asymmetric ECDSA | |37| PS256/384/512 | RSASSA-PSS | |38| EdDSA (Ed25519/Ed448) | Asymmetric | |39| none | Unsigned | Critically insecure |4041**Additional pitfalls:**42- JWS/JWE confusion: server accepts encrypted token (JWE) where signed (JWS) is expected, or fails open on unexpected `typ`/`cty`43- JWKS retrieval: SSRF via `jku`/`x5u`, insecure TLS, poisoned key caching, `kid` collisions44- Token binding (DPoP, mTLS): incorrectly implemented allows replay from other clients4546## Hunt: Identifying JWT Usage47481. Check `Authorization: Bearer <token>` headers in all requests492. Look for cookies containing JWT structures (`eyJ...`)503. Examine browser local/session storage514. Decode the token at jwt.io or via BurpSuite JWT extension — inspect claims and header parameters525. Note any `kid`, `jku`, `jwk`, `x5u` fields in the header — these are attack surfaces5354## Vulnerability Map5556```57JWT Vulnerabilities58├── Algorithm Bypass59│ ├── alg:none attack60│ └── RS256→HS256 confusion (public key as HMAC secret)61├── Weak Secret Key → Brute force62├── kid Parameter Injection63│ ├── SQL injection via kid64│ └── Path traversal via kid65├── Header Injection66│ ├── jwk (inline fake key)67│ ├── jku/x5u (remote attacker-controlled JWKS)68│ └── JWKS cache poisoning69└── Missing / Broken Validation70 ├── No signature check71 ├── Expired tokens accepted72 └── iss/aud/exp not validated73```7475## Vulnerabilities7677### Algorithm Vulnerabilities7879- **alg:none** — Some libraries disable signature validation when `alg` is `none` or a case variant (`None`, `NONE`, `nOnE`)80- **Algorithm Confusion (RS256→HS256)** — Server uses RSA public key as HMAC secret when attacker switches `alg` to HS256; attacker re-signs token with the public key81- **Key ID (`kid`) Manipulation** — Exploiting `kid` to load wrong keys or inject file paths / SQL; enforce strict lookups8283### Signature Vulnerabilities8485- **Weak HMAC Secrets** — Brute-forceable with dictionary or hashcat86- **Missing Signature Validation** — Token accepted without any verification87- **Broken Validation** — Implementation errors in signature checking logic8889### Implementation Issues9091- **Missing Claims Validation** — `exp`, `nbf`, `aud`, `iss` not verified92- **Insufficient Entropy** — Predictable JWT IDs or tokens93- **No Expiration** — Tokens valid indefinitely94- **Insecure Transport** — Token sent over HTTP95- **Debug Leakage** — Detailed error messages expose implementation9697### Header Injection Attacks9899- **JWK Injection** — Supply a custom attacker-controlled public key via the `jwk` header100- **JKU Manipulation** — Point `jku` (JWK Set URL) to attacker-controlled JWKS endpoint101- **x5u Misuse** — Load untrusted X.509 key URL; exploit lax TLS validation or open redirects102- **JWKS Cache Poisoning** — Force caches to accept attacker keys via `kid` collisions or response header manipulation103- **`crit` Header Abuse** — Server ignores unknown critical parameters, enabling bypass104105### Information Disclosure106107- Sensitive data (PII, credentials, session details) stored unencrypted in payload108- Internal service/backend information leaked via claims109110## Additional Attack Vectors111112### Mobile App JWT Storage113114**Android:**115- `SharedPreferences`: Check if world-readable; location `/data/data/<package>/shared_prefs/`116- Keystore extraction: root device or exploit app117- Backup extraction: `adb backup -f backup.ab <package>` (if `allowBackup=true`)118- Tools: Frida, objection, MobSF119120**iOS:**121- Keychain: Check `kSecAttrAccessible` — `kSecAttrAccessibleAlways` is insecure122- iTunes/iCloud backup extraction: unencrypted backups expose Keychain123- Jailbreak + Keychain-Dumper for full extraction124- Tools: Frida, objection, idb125126**React Native / Hybrid:**127- `AsyncStorage` stored in plain text (Android SQLite DB, iOS plist); no encryption by default128129```bash130# Android — check SharedPreferences131adb shell "run-as com.target.app cat /data/data/com.target.app/shared_prefs/auth.xml"132133# iOS — extract from backup134idevicebackup2 backup --full /path/to/backup135# Use plist/sqlite tools to extract JWT136```137138### JWT Confusion Attacks139140- **SAML-JWT Confusion** — App accepts both SAML and JWT; send JWT where SAML expected or vice versa to exploit weaker validation path141- **API Key-JWT Confusion** — Test sending JWT where API key expected and vice versa142- **Session Cookie-JWT Hybrid** — Test expired JWT with valid session cookie; inject JWT claims into session143- **OAuth Token Confusion** — Send ID token (JWT) to resource server expecting opaque access token144145```bash146# Try API key where JWT expected147curl -H "Authorization: Bearer <api_key>" https://api.target/resource148149# Try JWT where API key expected150curl -H "X-API-Key: <jwt_token>" https://api.target/resource151```152153> 📎 Detailed content (full examples / references / data tables) has been split into `reference.md` in the same directory; use Read to load the relevant section on demand.