npx skills add ...
npx skills add snailsploit/claude-red --skill offensive-jwt
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 injection, JWKS cache poisoning, JWS/JWE confusion, timing attacks, and mobile JWT storage extraction. Use when testing JWT-based authentication, hunting auth bypass via token manipulation, or evaluating JWT implementation security in web or mobile apps.
npx skills add snailsploit/claude-red --skill offensive-jwt
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.
none — signature verification bypassed entirelyRSA and HMAC (confusion attack)kid, jku, jwk, x5u header parameters accepted without validationUseful tool: JWT Tool
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:
typ/ctyjku/x5u, insecure TLS, poisoned key caching, kid collisionsAuthorization: Bearer <token> headers in all requestseyJ...)kid, jku, jwk, x5u fields in the header — these are attack surfacesalg is none or a case variant (None, NONE, nOnE)alg to HS256; attacker re-signs token with the public keykid) Manipulation — Exploiting kid to load wrong keys or inject file paths / SQL; enforce strict lookupsexp, nbf, aud, iss not verifiedjwk headerjku (JWK Set URL) to attacker-controlled JWKS endpointkid collisions or response header manipulationcrit Header Abuse — Server ignores unknown critical parameters, enabling bypassAndroid:
SharedPreferences: Check if world-readable; location /data/data/<package>/shared_prefs/adb backup -f backup.ab <package> (if allowBackup=true)iOS:
kSecAttrAccessible — kSecAttrAccessibleAlways is insecureReact Native / Hybrid:
AsyncStorage stored in plain text (Android SQLite DB, iOS plist); no encryption by defaultNon-constant-time comparison leaks the HMAC secret character by character via response time differences.
Referer header to external sites; CDN/cache logs may persist tokensCheck Wayback Machine for historical URLs with tokens; monitor Referer headers to third-party analytics.
Decode and Inspect:
Test none Algorithm (try all case variants):
Algorithm Confusion (RS256→HS256):
kid Parameter Attacks:
JWK/JKU Injection:
x5u / crit Handling:
Brute Force HMAC Secret:
Test Missing Claim Validation:
exp (expiration)iss (issuer) or aud (audience)iat (issued at) or nbf (not before)Other tools:
aud (audience) and iss (issuer) claimsnone algorithm; prevent algorithm downgrades; pin alg per client/issueralg; reject mismatchescrit header parametersjku/x5u except trusted domains; short-TTL key caching with kid uniquenessjti for early revocationtyp:"dpop+jwt"): verify proof binds to HTTP request; enforce one-time nonce useSameSite=Lax/Strict HttpOnly cookies for web; avoid localStorage for access tokens# 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# 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/resourceimport requests, time
def time_request(signature):
start = time.perf_counter()
r = requests.get('https://target/api',
headers={'Authorization': f'Bearer header.payload.{signature}'})
return time.perf_counter() - start
# Brute-force first byte — longer response time indicates correct byte
for byte in range(256):
sig = bytes([byte]) + b'\x00' * 31
t = time_request(sig.hex())curl "https://api.target/resource?token=eyJ..."
curl "https://api.target/resource?access_token=eyJ..."
curl "https://api.target/resource?jwt=eyJ..."