Skip to content
Back to skills

Sc Jwt

ASecurity

JWT implementation flaw detection — algorithm confusion, weak secrets, missing validation, and storage issues

  • 4 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 12, 2026
securityjavascriptpythongojavasqlawsgitapisecurity

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 12, 2026

npx -y skills add aibot88/sec_skill_store --skill sc-jwt --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sc Jwt?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Sc Jwt
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aibot88-sc-jwt/badge)](https://www.skillsdirectory.com/skills/aibot88-sc-jwt)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: sc-jwt
description: JWT implementation flaw detection — algorithm confusion, weak secrets, missing validation, and storage issues
license: MIT
metadata:
  category: security
  version: "1.0.0"
---

# SC: JWT Implementation Flaws

## Purpose

Detects JWT (JSON Web Token) implementation vulnerabilities including algorithm confusion attacks (alg:none, RS256→HS256), weak signing secrets, missing expiration/audience/issuer validation, insecure client-side storage, JWK injection, and key ID (kid) manipulation.

## Activation

Called by sc-orchestrator during Phase 2 when JWT usage is detected.

## Phase 1: Discovery

### Keyword Patterns to Search
```
"jwt", "JWT", "jsonwebtoken", "jose", "PyJWT", "java-jwt",
"sign(", "verify(", "decode(", "encode(",
"alg", "HS256", "RS256", "ES256", "none",
"expiresIn", "exp", "iat", "aud", "iss", "sub",
"localStorage.*token", "sessionStorage.*token",
"Bearer", "Authorization"
```

### Vulnerability Patterns

**1. Algorithm Confusion (alg:none):**
```javascript
// VULNERABLE: Not specifying allowed algorithms
const payload = jwt.verify(token, secret);  // Accepts alg:none!

// SAFE: Specify algorithms explicitly
const payload = jwt.verify(token, secret, { algorithms: ['HS256'] });
```

**2. Weak Signing Secret:**
```javascript
// VULNERABLE: Short/predictable secret
const token = jwt.sign(payload, 'secret');
const token = jwt.sign(payload, 'password123');
const token = jwt.sign(payload, process.env.JWT_SECRET || 'default');

// SAFE: Strong random secret (256+ bits)
const token = jwt.sign(payload, process.env.JWT_SECRET);
// Where JWT_SECRET is a 64+ character random string
```

**3. Missing Expiration:**
```python
# VULNERABLE: No expiration
token = jwt.encode({"user_id": user.id}, SECRET_KEY, algorithm="HS256")

# SAFE: With expiration
token = jwt.encode({
    "user_id": user.id,
    "exp": datetime.utcnow() + timedelta(hours=1)
}, SECRET_KEY, algorithm="HS256")
```

**4. JWT in localStorage (XSS Theft):**
```javascript
// VULNERABLE: XSS can steal token
localStorage.setItem('token', jwtToken);

// SAFE: HttpOnly cookie
res.cookie('token', jwtToken, {
  httpOnly: true,
  secure: true,
  sameSite: 'strict'
});
```

**5. Missing Audience/Issuer Validation:**
```javascript
// VULNERABLE: No audience/issuer check
const payload = jwt.verify(token, secret, { algorithms: ['HS256'] });

// SAFE: Validate audience and issuer
const payload = jwt.verify(token, secret, {
  algorithms: ['HS256'],
  audience: 'https://api.example.com',
  issuer: 'https://auth.example.com'
});
```

**6. Kid Parameter Injection:**
```javascript
// VULNERABLE: kid used in SQL query or file path
const kid = header.kid;
const key = db.query(`SELECT key FROM keys WHERE id = '${kid}'`);  // SQL injection!
// Or: const key = fs.readFileSync(`/keys/${kid}`);  // Path traversal!
```

## Severity Classification

- **Critical:** Algorithm confusion allowing token forgery, SQL injection via kid
- **High:** Weak signing secret (guessable), missing algorithm validation
- **Medium:** JWT in localStorage (requires XSS), missing expiration
- **Low:** Missing audience/issuer validation, long expiration time

## Output Format

### Finding: JWT-{NNN}
- **Title:** JWT {vulnerability type}
- **Severity:** Critical | High | Medium | Low
- **Confidence:** 0-100
- **File:** file/path:line
- **Vulnerability Type:** CWE-345 (Insufficient Verification of Data Authenticity) | CWE-347 (Improper Verification of Cryptographic Signature)
- **Description:** {What was found}
- **Impact:** Authentication bypass, token forgery, account takeover.
- **Remediation:** {Specify algorithms, use strong secrets, validate exp/aud/iss, store in httpOnly cookies}
- **References:** https://cwe.mitre.org/data/definitions/345.html

## Common False Positives

1. **JWT decode (not verify)** — `jwt.decode()` for reading payload (without verification) in non-auth contexts
2. **Test tokens** — hardcoded tokens in test files
3. **Public key operations** — RS256 verification with public key is safe (no secret needed)
4. **Token refresh logic** — legitimate token reissuance patterns

Files in this skill

  • SKILL.md4 KB
  • source.json591 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.