一键导入
jwt-algorithm-confusion-prevention
Prevent algorithm confusion attacks when validating JWTs — RS256 tokens accepted as HS256
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Prevent algorithm confusion attacks when validating JWTs — RS256 tokens accepted as HS256
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Convert PDF/EPUB library to Markdown and generate Obsidian MOC notes
Hook-based compaction suggestions at logical task boundaries
Context window management — track spend, decide when to compact, preserve state
Session-start orientation — loads context, surfaces learnings, confirms registry
Quality and semantic review — catches what automated tools miss
Planner → Architect → Critic deliberation loop — produces a formally validated ADR
| name | jwt-algorithm-confusion-prevention |
| description | Prevent algorithm confusion attacks when validating JWTs — RS256 tokens accepted as HS256 |
| version | 0.1.0 |
| level | 2 |
| triggers | ["jwt validation","token verification","verify jwt"] |
| context_files | [] |
| steps | [{"name":"Check Algorithm Enforcement","description":"Verify the JWT library is configured to accept only the expected algorithm explicitly"},{"name":"Check Key Type Match","description":"Confirm the key type matches the declared algorithm — RSA key for RS256, secret for HS256"},{"name":"Check None Algorithm Rejection","description":"Verify the library rejects the \"none\" algorithm"}] |
Note: This is an example learned skill showing the format. Replace it with skills captured from your actual codebase using the learner skill.
JWT libraries that accept any algorithm will validate an RS256-signed token as HS256 if you use the public RSA key as the HMAC secret. The attacker signs a token with the public key using HS256 — the library accepts it because the signature is valid under HS256 with that key. This is not a theoretical attack.
The symptom that brings you here: authentication bypass with valid-looking tokens. No error in logs. The token passes signature verification. The bug is invisible unless you know to look for it.
This skill applies when:
Explicit algorithm allowlist at configuration time, not call time.
Wrong — algorithm from token header trusted:
jwt.decode(token, key) # uses alg from token header
Right — algorithm enforced by verifier:
jwt.decode(token, key, algorithms=["RS256"]) # rejects anything else
Also verify:
"none" algorithm is explicitly rejected (not just "not in the list" — some libraries require explicit rejection)"none" algorithm is explicitly rejected