Security Audit
Identify security vulnerabilities in the codebase. This skill finds problems; for remediation, use the /security-hardening skill.
Instructions
Perform a systematic security audit following these steps:
Automated Dependency Scan
Run the appropriate audit command for the detected ecosystem as the first step:
- Node.js:
npm audit or yarn audit
- Python:
pip-audit or safety check
- Go:
govulncheck ./...
- Rust:
cargo audit
- Ruby:
bundle audit check
- Java:
mvn dependency-check:check or gradle dependencyCheckAnalyze
Record all findings with their CVE IDs before proceeding.
Environment and Stack Assessment
- Identify the technology stack, framework, and runtime
- Check for existing security tools and configurations (linters, SAST, WAF)
- Review deployment and infrastructure setup
Authentication and Authorization
- Review authentication mechanisms (OAuth, JWT, sessions, API keys)
- Check session management: expiry, rotation, invalidation
- Verify authorization controls: role checks, resource-level permissions
- Examine password policies and storage (bcrypt, argon2 vs. plaintext/MD5)
Input Validation and Injection
- Check all user input paths for validation and sanitization
- Look for SQL injection: raw queries, string concatenation with user input
- Identify XSS vectors: unescaped output, unsafe innerHTML usage, template injection
- Review file upload handling: type validation, size limits, storage location
Data Protection
- Identify sensitive data (PII, credentials, financial data) and how it flows through the system
- Check encryption at rest (database, file storage) and in transit (TLS configuration)
- Review data masking in logs, error messages, and API responses
- Verify secure protocols: TLS 1.2+, no mixed content
Secrets Management
- Scan for hardcoded secrets, API keys, and passwords in source code
- Check
.env files, config files, and CI/CD variables for exposed secrets
- Verify secrets are loaded from a vault or environment, not committed to the repo
- Check
.gitignore for proper exclusion of sensitive files
Error Handling and Logging
- Review error messages for information disclosure (stack traces, DB schemas, internal paths)
- Check that sensitive data is never logged (tokens, passwords, PII)
- Verify security events are logged (failed logins, permission denials, input validation failures)
Infrastructure Security
- Review container security: base image, running as non-root, no secrets in layers
- Check CI/CD pipeline: secret injection, artifact signing, dependency pinning
- Examine cloud permissions: least-privilege IAM, public bucket/storage exposure
- Review network configuration: open ports, security groups, firewall rules
Security Headers and CORS
- Check HTTP security headers:
Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options, Referrer-Policy
- Review CORS configuration: overly permissive origins, credential handling
- Verify CSP (Content Security Policy) is present and restrictive
- Examine cookie attributes:
Secure, HttpOnly, SameSite
Report Findings
Document all findings using the severity format below. Include specific file paths and line numbers.
Output Format
Rate each finding using CVSS-aligned severity:
### [CRITICAL] Hardcoded database password in source code
**File:** `src/config/database.ts:14`
**CWE:** CWE-798 (Use of Hard-coded Credentials)
**Description:** Production database password is committed in plaintext.
**Impact:** Full database access if source code is exposed.
**Remediation:** Move to environment variable or secrets manager.
### [HIGH] SQL injection in user search endpoint
**File:** `src/routes/users.ts:67`
**CWE:** CWE-89 (SQL Injection)
**Description:** User-supplied `query` parameter is concatenated directly into SQL string.
**Impact:** Attacker can read, modify, or delete arbitrary database records.
**Remediation:** Use parameterized queries or ORM query builder.
### [MEDIUM] Missing rate limiting on login endpoint
**File:** `src/routes/auth.ts:23`
**CWE:** CWE-307 (Improper Restriction of Excessive Authentication Attempts)
**Description:** No rate limiting or account lockout on `/api/login`.
**Impact:** Enables brute-force password attacks.
**Remediation:** Add rate limiting middleware (e.g., express-rate-limit).
### [LOW] Verbose error messages in production
**File:** `src/middleware/error-handler.ts:8`
**CWE:** CWE-209 (Information Exposure Through Error Messages)
**Description:** Stack traces are returned in API error responses when NODE_ENV is not set.
**Impact:** Leaks internal file paths and dependency versions.
**Remediation:** Default to production mode; return generic error messages.
Severity levels:
- CRITICAL - Exploitable now with severe impact (data breach, RCE, full system compromise)
- HIGH - Exploitable with significant impact or requires minimal prerequisites
- MEDIUM - Requires specific conditions to exploit or has limited blast radius
- LOW - Informational or defense-in-depth improvement
Follow-Up
For fixing the vulnerabilities found in this audit, use the /security-hardening skill to generate remediation steps and hardened code.
1---2name: security-audit3description: Identify security vulnerabilities across dependencies, auth, input validation, data protection, secrets, and infrastructure4---56# Security Audit78Identify security vulnerabilities in the codebase. This skill **finds** problems; for remediation, use the `/security-hardening` skill.910## Instructions1112Perform a systematic security audit following these steps:13141. **Automated Dependency Scan**15 Run the appropriate audit command for the detected ecosystem as the first step:16 - **Node.js:** `npm audit` or `yarn audit`17 - **Python:** `pip-audit` or `safety check`18 - **Go:** `govulncheck ./...`19 - **Rust:** `cargo audit`20 - **Ruby:** `bundle audit check`21 - **Java:** `mvn dependency-check:check` or `gradle dependencyCheckAnalyze`2223 Record all findings with their CVE IDs before proceeding.24252. **Environment and Stack Assessment**26 - Identify the technology stack, framework, and runtime27 - Check for existing security tools and configurations (linters, SAST, WAF)28 - Review deployment and infrastructure setup29303. **Authentication and Authorization**31 - Review authentication mechanisms (OAuth, JWT, sessions, API keys)32 - Check session management: expiry, rotation, invalidation33 - Verify authorization controls: role checks, resource-level permissions34 - Examine password policies and storage (bcrypt, argon2 vs. plaintext/MD5)35364. **Input Validation and Injection**37 - Check all user input paths for validation and sanitization38 - Look for SQL injection: raw queries, string concatenation with user input39 - Identify XSS vectors: unescaped output, unsafe innerHTML usage, template injection40 - Review file upload handling: type validation, size limits, storage location41425. **Data Protection**43 - Identify sensitive data (PII, credentials, financial data) and how it flows through the system44 - Check encryption at rest (database, file storage) and in transit (TLS configuration)45 - Review data masking in logs, error messages, and API responses46 - Verify secure protocols: TLS 1.2+, no mixed content47486. **Secrets Management**49 - Scan for hardcoded secrets, API keys, and passwords in source code50 - Check `.env` files, config files, and CI/CD variables for exposed secrets51 - Verify secrets are loaded from a vault or environment, not committed to the repo52 - Check `.gitignore` for proper exclusion of sensitive files53547. **Error Handling and Logging**55 - Review error messages for information disclosure (stack traces, DB schemas, internal paths)56 - Check that sensitive data is never logged (tokens, passwords, PII)57 - Verify security events are logged (failed logins, permission denials, input validation failures)58598. **Infrastructure Security**60 - Review container security: base image, running as non-root, no secrets in layers61 - Check CI/CD pipeline: secret injection, artifact signing, dependency pinning62 - Examine cloud permissions: least-privilege IAM, public bucket/storage exposure63 - Review network configuration: open ports, security groups, firewall rules64659. **Security Headers and CORS**66 - Check HTTP security headers: `Strict-Transport-Security`, `X-Content-Type-Options`, `X-Frame-Options`, `Referrer-Policy`67 - Review CORS configuration: overly permissive origins, credential handling68 - Verify CSP (Content Security Policy) is present and restrictive69 - Examine cookie attributes: `Secure`, `HttpOnly`, `SameSite`707110. **Report Findings**72 Document all findings using the severity format below. Include specific file paths and line numbers.7374## Output Format7576Rate each finding using CVSS-aligned severity:7778```markdown79### [CRITICAL] Hardcoded database password in source code80**File:** `src/config/database.ts:14`81**CWE:** CWE-798 (Use of Hard-coded Credentials)82**Description:** Production database password is committed in plaintext.83**Impact:** Full database access if source code is exposed.84**Remediation:** Move to environment variable or secrets manager.8586### [HIGH] SQL injection in user search endpoint87**File:** `src/routes/users.ts:67`88**CWE:** CWE-89 (SQL Injection)89**Description:** User-supplied `query` parameter is concatenated directly into SQL string.90**Impact:** Attacker can read, modify, or delete arbitrary database records.91**Remediation:** Use parameterized queries or ORM query builder.9293### [MEDIUM] Missing rate limiting on login endpoint94**File:** `src/routes/auth.ts:23`95**CWE:** CWE-307 (Improper Restriction of Excessive Authentication Attempts)96**Description:** No rate limiting or account lockout on `/api/login`.97**Impact:** Enables brute-force password attacks.98**Remediation:** Add rate limiting middleware (e.g., express-rate-limit).99100### [LOW] Verbose error messages in production101**File:** `src/middleware/error-handler.ts:8`102**CWE:** CWE-209 (Information Exposure Through Error Messages)103**Description:** Stack traces are returned in API error responses when NODE_ENV is not set.104**Impact:** Leaks internal file paths and dependency versions.105**Remediation:** Default to production mode; return generic error messages.106```107108Severity levels:109- **CRITICAL** - Exploitable now with severe impact (data breach, RCE, full system compromise)110- **HIGH** - Exploitable with significant impact or requires minimal prerequisites111- **MEDIUM** - Requires specific conditions to exploit or has limited blast radius112- **LOW** - Informational or defense-in-depth improvement113114## Follow-Up115116For fixing the vulnerabilities found in this audit, use the `/security-hardening` skill to generate remediation steps and hardened code.