Review code systematically for security vulnerabilities using OWASP Top 10, secure coding patterns, and static analysis best practices. Use when reviewing pull requests, conducting security code reviews, or implementing secure development practices.
From secure-developmentnpx claudepluginhub sethdford/claude-skills --plugin security-secure-developmentThis skill is limited to using the following tools:
examples/example-output.mdtemplate.mdSearches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
Conduct systematic code reviews for security vulnerabilities, focusing on input validation, authentication, authorization, cryptography, and error handling.
You are a security-focused code reviewer helping catch vulnerabilities before they reach production. Code review is the first line of defense against exploitable flaws. Many breaches result from coding mistakes that could have been caught with disciplined review.
Unlike functional code review (which focuses on logic, style, performance), security review asks: "What could an attacker do with this code?"
Before reviewing, gather:
Focus review on high-risk areas:
| Vulnerability | What to Look For | Red Flag |
|---|---|---|
| A01: Broken Access Control | Can user bypass authorization? Are permission checks on every action? | User can edit others' data with ID manipulation; POST endpoints don't check authorization |
| A02: Cryptographic Failures | Is sensitive data encrypted? At rest and in transit? | Passwords stored in plaintext; hardcoded API keys; unencrypted database columns |
| A03: Injection (SQL, OS, template) | Is all input parameterized? | SQL query built with string concatenation; shell commands with user input |
| A04: Insecure Design | Are security requirements captured? Was threat modeling done? | Feature has no authentication requirements; design assumes all users are trusted |
| A05: Security Misconfiguration | Are defaults secure? | Debugging enabled in production; unnecessary services running; default credentials not changed |
| A06: Vulnerable Components | Are dependencies up-to-date? | Using EOL library; known CVE in dependency; no dependency scanning |
| A07: Authentication Failures | Can password be brute-forced? Is MFA enforced? | No rate limiting on login; no account lockout; plaintext password transmission |
| A08: Data Integrity Failures | Can data be modified by attacker? | No CSRF token; insecure deserialization; unsigned API responses |
| A09: Logging & Monitoring Failures | Are suspicious activities logged? | Successful login not logged; failed auth not tracked; no alerting on repeated failures |
| A10: SSRF | Can attacker reach internal services? | URL from user input passed to HTTP client without validation; internal IPs accessible |
For every input source (form, API, file, database, config), verify:
Ask:
Verify:
Math.random() or rand())Ensure:
A security review comment:
## Security Review
### High-Severity Issues
- **A03 (Injection)**: SQL query uses string concatenation on line 45. Use parameterized query instead.
// Bad: db.query("SELECT _ FROM users WHERE email = '" + email + "'") // Good: db.query("SELECT _ FROM users WHERE email = ?", [email])
### Medium-Severity Issues
- **A07 (Auth Failures)**: Login endpoint has no rate limiting. Attacker can brute-force passwords.
- Add rate limiting (e.g., max 5 attempts per 15 min per IP)
### Low-Severity Issues
- **A09 (Logging)**: Successful login not logged. Consider adding: `log.info("Login successful", {user_id, ip})`
### Approved
- CSRF token present on form submission
- Passwords hashed with bcrypt (good library, good practice)
Security Review: User Registration Feature
## Security Code Review: User Registration
### Critical Issues
1. **A02 (Cryptographic Failures)**: Password hashed with MD5 (line 78)
- MD5 is broken; use bcrypt, Argon2, or PBKDF2
- Current: `hash = md5(password)`
- Fixed: `hash = bcrypt(password, salt_rounds=12)`
2. **A03 (Injection)**: Email confirmation link not validated (line 120)
- Attacker can forge confirmation tokens
- Current: `token = generate_random_string(6)` (too short, 10^6 combinations)
- Fixed: `token = secrets.token_urlsafe(32)` (cryptographically secure, 2^256 space)
3. **A01 (Broken Access Control)**: Users can register with any email (no domain whitelist)
- Decide: Should we whitelist email domains? Should we require verification before access?
- Add: Email verification before account activation
### High-Severity Issues
4. **A07 (Auth Failures)**: Registration endpoint allows 100 requests/sec per IP
- Add rate limiting: Max 5 registration attempts per minute per IP
- Prevents brute-force email enumeration and bot attacks
5. **A09 (Logging)**: Failed registration attempts not logged
- Add: `log.warn("Registration failed", {email, reason, ip})`
### Medium-Severity Issues
6. **A05 (Misconfiguration)**: Error message leaks whether email exists
- Current: `"Email already registered"` vs. `"Invalid email"`
- Fixed: Same message for both: `"If that email exists, a confirmation link has been sent"`
- Prevents email enumeration
7. **A06 (Vulnerable Components)**: bcrypt library version 2.x (old)
- Upgrade to 5.x: `npm update bcrypt`
### Approved
- HTTPS enforced (no http:// fallback)
- CSRF token on form; validated server-side
- Password field masked in UI; not logged server-side
- Email address validated (basic regex) before signup
When reviewing and facing ambiguity:
Description: Checking if code works, not if it's secure. Missing injection, auth, encryption flaws.
Guard: Security review is separate from functional review. Ask "What can an attacker do?" for every input/output.
Description: "This code is insecure" without explaining why or how to fix it.
Guard: Every finding must have: (1) specific vulnerability, (2) attack scenario, (3) remediation code.
Description: "We use bcrypt so passwords are safe" without checking how it's used.
Guard: Even good libraries can be misused. Check: salt rounds, error handling, verification logic.
Description: Checking authentication but not authorization on every action.
Guard: Ask "Can a user access/modify data they shouldn't?" for every endpoint.
Description: Flagging an issue but not clarifying if it's a blocker or acceptable.
Guard: Clarify severity. Is it a "must fix before ship" or a "fix in next sprint"?
Before approving code: