sast-jwt
Detect JWT (JSON Web Token) vulnerabilities in authentication middleware and API routes. Use when reviewing token validation, session handling, or any code that parses/verifies JWTs. Covers algorithm confusion, none algorithm, weak secrets, and missing validation.
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-05
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- sast-jwt
- description
- Detect JWT (JSON Web Token) vulnerabilities in authentication middleware and API routes. Use when reviewing token validation, session handling, or any code that parses/verifies JWTs. Covers algorithm confusion, none algorithm, weak secrets, and missing validation.
03 SKILL.md 正文
SAST: JWT Vulnerability Detection
Scan for JWT implementation flaws — OWASP A02:2021 (Cryptographic Failures).
What to Look For
Critical Patterns
// ❌ CRITICAL: accepting 'none' algorithm
jwt.verify(token, secret, { algorithms: ['HS256', 'none'] });
// ❌ CRITICAL: not specifying algorithm (algorithm confusion attack)
jwt.verify(token, publicKey); // if RS256 expected but HS256 sent with publicKey as secret
// ❌ CRITICAL: weak or hardcoded secret
const secret = 'secret';
const secret = '12345';
const secret = process.env.JWT_SECRET || 'fallback-secret'; // fallback is dangerous
// ❌ CRITICAL: not verifying token before using claims
const decoded = jwt.decode(token); // decode ≠ verify!
const userId = decoded.sub; // attacker controls this
// ❌ HIGH: no expiry validation
jwt.sign(payload, secret); // no expiresIn — token lives forever
Safe Patterns
// ✅ SAFE: explicit algorithm, no fallback secret
const secret = process.env.JWT_SECRET;
if (!secret) throw new Error('JWT_SECRET not configured');
const payload = jwt.verify(token, secret, { algorithms: ['HS256'] });
// ✅ SAFE: short-lived tokens
jwt.sign(payload, secret, { expiresIn: '15m', algorithm: 'HS256' });
// ✅ SAFE: Firebase ID tokens (Kalmeron uses this)
const decoded = await admin.auth().verifyIdToken(idToken);
Kalmeron-Specific Notes
- Kalmeron uses Firebase Auth → Firebase SDK handles JWT verification internally
- Check
src/lib/auth/session.tsand middleware for any custom JWT handling - If custom JWTs are issued (e.g., for API keys), verify the above patterns
Scan Checklist
- [ ] Algorithm explicitly specified in
jwt.verify()— never allow 'none' - [ ]
jwt.verify()used (notjwt.decode()) for authentication - [ ] JWT_SECRET loaded from environment — no hardcoded fallbacks
- [ ] Tokens have expiry (
expiresIn) - [ ] Token revocation strategy exists (blocklist or short TTL)
- [ ] Firebase ID tokens verified via
admin.auth().verifyIdToken()
Severity Matrix
| Pattern | Severity |
|---|---|
| Algorithm confusion (RS256→HS256) | Critical |
none algorithm accepted |
Critical |
jwt.decode() used for auth |
Critical |
| Hardcoded JWT secret | High |
| No token expiry | High |
| Missing algorithm specification | High |
Remediation
- Always specify
algorithms: ['HS256']in verify options - Never use
jwt.decode()for security decisions - Store secrets in environment variables with no defaults
- Set
expiresIn: '15m'for access tokens,7dfor refresh tokens - Implement token rotation and revocation for sensitive operations
04 同仓库更多 Skills
skill-creator
To create new CLI skills following Anthropic's official best practices with zero manual configuration. This skill automates brainstorming, template application, validation, and installation processes while maintaining progressive disclosure patterns and writing style standards.
business-investment-advisor
Business investment analysis and capital allocation advisor. Use when evaluating whether to invest in equipment, real estate, a new business, hiring, technology, or any capital expenditure. Also use for ROI calculations, IRR, NPV, payback period, build vs buy decisions, lease vs buy analysis, vendor evaluation, or deciding where to allocate limited budget for maximum return.
add-new-agent
خطوات تفصيليّة لإضافة وكيل ذكاء اصطناعي جديد إلى منصّة Kalmeron من الفكرة إلى الإنتاج
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
writing-plans
Use when you have a spec or requirements for a multi-step task, before touching code
web-design-guidelines
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".