Security Audit Skill
Execute a comprehensive, end-to-end security audit on the current codebase. Inspect source code, configurations, dependencies, and environment files to identify and remediate security vulnerabilities across 19 critical checkpoints.
🎯 Scope & Objectives
When invoked (/security-audit or when asked to perform a security check), analyze the repository against the following 6 domain modules:
Module 1: Dependencies & Package Health
- Remove Unused Packages: Identify unused npm, pip, go, or cargo dependencies and propose removal.
- Update Dependencies: Scan for out-of-date or vulnerable package versions (
npm audit, pip-audit, cargo audit, or equivalent).
Module 2: Secrets & Environment Management
- Check Git for Secrets: Scan commit history and stage area for hardcoded keys, JWT secrets, passwords, or tokens using tools like
trufflehog or regex pattern matching.
- Hide API Keys: Verify that external API keys are excluded from source control and loaded strictly via environment variables.
- Check Environment Variables: Audit
.env.example templates to ensure sensitive defaults are not checked into Git, and verify proper runtime validation of required .env keys.
- Check Exposed Files: Ensure sensitive files (
.env, .pem, .key, id_rsa, .DS_Store, database dumps, build artifacts) are properly listed in .gitignore.
Module 3: Authentication & Access Control
- Proper Authentication: Verify session management, token handling (HTTP-only cookies vs. local storage), and token expiration/invalidation strategies.
- Hash Passwords Properly: Ensure password hashing uses strong, modern algorithms (e.g., Argon2id, bcrypt with cost factor ≥12, scrypt) with appropriate salts—never plain SHA-256 or MD5.
- Check User Access: Audit Role-Based Access Control (RBAC) and Attribute-Based Access Control (ABAC) implementation across authorization middleware.
- Protect Admin Routes: Verify that privileged routes and endpoints require explicitly validated administrator scopes/roles and cannot be bypassed via parameter tampering.
Module 4: API & Endpoint Protection
- Secure API Endpoints: Ensure all public/private endpoints validate authorization headers, enforce proper HTTP verbs, and avoid mass assignment vulnerabilities.
- Add Rate Limiting: Verify rate-limiting middleware is applied to sensitive endpoints (login, password reset, public APIs, payment routes) to prevent brute-force and DoS attacks.
- Check CORS Settings: Inspect Cross-Origin Resource Sharing configurations to ensure wildcard origins (
*) are prohibited in production setups with credentials.
- Secure DB Access: Check for parameterized queries / ORM usage to prevent SQL/NoSQL injection, and verify database connection strings use SSL/TLS with least-privilege accounts.
Module 5: Input Handling & Frontend Security
- Sanitize Forms: Ensure all user inputs undergo strict server-side validation and sanitization.
- Protect Against XSS: Audit template engines, React/Vue/Svelte renders, and HTML outputs to ensure proper contextual escaping and absence of unsafe functions (e.g.,
dangerouslySetInnerHTML, eval(), innerHTML).
Module 6: System Configuration & Hardening
- Disable Debug Mode: Verify debug flags, detailed stack traces, and verbose logging are disabled for production builds.
- Add Security Headers: Ensure defensive HTTP response headers are set (Content-Security-Policy, Strict-Transport-Security, X-Frame-Options, X-Content-Type-Options, Referrer-Policy).
- Full Security Audit Integration: Synthesize findings across all 18 rules into a consolidated risk matrix with clear severity scores (Critical, High, Medium, Low).
🛠️ Execution Instructions for Claude Code
When executing this skill:
Information Gathering:
- Scan package manifests (
package.json, requirements.txt, Cargo.toml, go.mod, pom.xml).
- Inspect build configurations,
.gitignore, .env templates, server entry points, and routing files.
- Actually run the dependency-vulnerability command for whichever manifest is present — do not just describe what it might find. Match the manifest to its tool:
package.json → npm audit --json (or pnpm audit / yarn audit if that lockfile is present instead), requirements.txt → pip-audit, Cargo.toml → cargo audit, go.mod → govulncheck ./.... If more than one manifest is present, run each.
- If the matching tool isn't installed, don't skip the checkpoint silently — say so explicitly in the report (e.g., "Update Dependencies: not run,
pip-audit is not installed in this environment") rather than omitting it or treating it as a pass.
Codebase Inspection:
- Run pattern-matching scans for credentials and secrets across the workspace.
- Trace authentication workflows, route protection middleware, and database queries.
- Audit response headers and application settings.
Report Generation:
- Group findings by severity (Critical, High, Medium, Low).
- Provide concrete code references (
file_path:line_number).
- Deliver actionable code patches and remediation commands for every identified vulnerability.
📋 Output Format
Format the audit output using the following markdown structure:
# 🛡️ Security Audit Findings
## Executive Summary
- **Total Issues Found:** X
- **Risk Breakdown:** 🔴 Critical: A | 🟠 High: B | 🟡 Medium: C | 🟢 Low: D
---
## 🔴 Critical & High Vulnerabilities
### 1. [Vulnerability Title]
- **Category:** [e.g., Secrets Exposure / Module 2]
- **File:** `path/to/file.ext:42`
- **Impact:** [Brief description of real-world exploitation risk]
- **Current Code:**
```language
// Problematic snippet
- Remediation:
// Corrected snippet
- Remediation Command (if applicable):
npm install package@latest
(Repeat per Critical/High finding.)
🟡 Medium & 🟢 Low Vulnerabilities
N. [Finding Title]
- Category: [Module reference]
- File:
path/to/file.ext:line
- Impact: [Brief description]
- Recommendation: [Concrete fix, one or two lines]
(Repeat per Medium/Low finding. These may be listed more tersely than Critical/High.)
✅ Passed Checks
List checkpoints (by number, 1–19) that were inspected and found compliant, so the report shows full coverage rather than only problems.
📊 Risk Matrix
| # |
Checkpoint |
Module |
Status |
Severity |
| 1 |
Remove Unused Packages |
1 |
⚠️ Issue |
Low |
| 2 |
Update Dependencies |
1 |
✅ Pass |
— |
| … |
… |
… |
… |
… |
🧭 Next Steps
Ordered remediation checklist, Critical first, with the estimated effort for each (e.g., "single-line fix" vs. "requires design change").
---
## ⚠️ Ground Rules
- **Never fabricate a finding.** Every reported issue must cite a real file and line; if a checkpoint cannot be verified (no test runner, no lockfile, etc.), say so in Passed Checks / a "Not Applicable" note rather than guessing.
- **Never auto-apply fixes without being asked.** This skill reports and proposes remediation; it does not silently rewrite auth, database, or payment code. Ask before editing anything security-critical.
- **Read secrets, never print them.** When Module 2 checks turn up a real credential, report its location and redact the value in the report itself.
- **Prefer the project's existing tools.** Use whatever audit/lint tooling the repo already has configured (`npm audit`, `pip-audit`, existing ESLint security rules) before reaching for an external scanner.
1---2name: security-audit3description: Audits codebases for security vulnerabilities, secrets exposure, auth risks, dependency health, and misconfigurations.4---56# Security Audit Skill78Execute a comprehensive, end-to-end security audit on the current codebase. Inspect source code, configurations, dependencies, and environment files to identify and remediate security vulnerabilities across 19 critical checkpoints.910---1112## 🎯 Scope & Objectives1314When invoked (`/security-audit` or when asked to perform a security check), analyze the repository against the following 6 domain modules:1516### Module 1: Dependencies & Package Health171. **Remove Unused Packages:** Identify unused npm, pip, go, or cargo dependencies and propose removal.182. **Update Dependencies:** Scan for out-of-date or vulnerable package versions (`npm audit`, `pip-audit`, `cargo audit`, or equivalent).1920### Module 2: Secrets & Environment Management213. **Check Git for Secrets:** Scan commit history and stage area for hardcoded keys, JWT secrets, passwords, or tokens using tools like `trufflehog` or regex pattern matching.224. **Hide API Keys:** Verify that external API keys are excluded from source control and loaded strictly via environment variables.235. **Check Environment Variables:** Audit `.env.example` templates to ensure sensitive defaults are not checked into Git, and verify proper runtime validation of required `.env` keys.246. **Check Exposed Files:** Ensure sensitive files (`.env`, `.pem`, `.key`, `id_rsa`, `.DS_Store`, database dumps, build artifacts) are properly listed in `.gitignore`.2526### Module 3: Authentication & Access Control277. **Proper Authentication:** Verify session management, token handling (HTTP-only cookies vs. local storage), and token expiration/invalidation strategies.288. **Hash Passwords Properly:** Ensure password hashing uses strong, modern algorithms (e.g., Argon2id, bcrypt with cost factor ≥12, scrypt) with appropriate salts—never plain SHA-256 or MD5.299. **Check User Access:** Audit Role-Based Access Control (RBAC) and Attribute-Based Access Control (ABAC) implementation across authorization middleware.3010. **Protect Admin Routes:** Verify that privileged routes and endpoints require explicitly validated administrator scopes/roles and cannot be bypassed via parameter tampering.3132### Module 4: API & Endpoint Protection3311. **Secure API Endpoints:** Ensure all public/private endpoints validate authorization headers, enforce proper HTTP verbs, and avoid mass assignment vulnerabilities.3412. **Add Rate Limiting:** Verify rate-limiting middleware is applied to sensitive endpoints (login, password reset, public APIs, payment routes) to prevent brute-force and DoS attacks.3513. **Check CORS Settings:** Inspect Cross-Origin Resource Sharing configurations to ensure wildcard origins (`*`) are prohibited in production setups with credentials.3614. **Secure DB Access:** Check for parameterized queries / ORM usage to prevent SQL/NoSQL injection, and verify database connection strings use SSL/TLS with least-privilege accounts.3738### Module 5: Input Handling & Frontend Security3915. **Sanitize Forms:** Ensure all user inputs undergo strict server-side validation and sanitization.4016. **Protect Against XSS:** Audit template engines, React/Vue/Svelte renders, and HTML outputs to ensure proper contextual escaping and absence of unsafe functions (e.g., `dangerouslySetInnerHTML`, `eval()`, `innerHTML`).4142### Module 6: System Configuration & Hardening4317. **Disable Debug Mode:** Verify debug flags, detailed stack traces, and verbose logging are disabled for production builds.4418. **Add Security Headers:** Ensure defensive HTTP response headers are set (Content-Security-Policy, Strict-Transport-Security, X-Frame-Options, X-Content-Type-Options, Referrer-Policy).4519. **Full Security Audit Integration:** Synthesize findings across all 18 rules into a consolidated risk matrix with clear severity scores (Critical, High, Medium, Low).4647---4849## 🛠️ Execution Instructions for Claude Code5051When executing this skill:52531. **Information Gathering:**54 - Scan package manifests (`package.json`, `requirements.txt`, `Cargo.toml`, `go.mod`, `pom.xml`).55 - Inspect build configurations, `.gitignore`, `.env` templates, server entry points, and routing files.56 - **Actually run the dependency-vulnerability command for whichever manifest is present** — do not just describe what it might find. Match the manifest to its tool: `package.json` → `npm audit --json` (or `pnpm audit` / `yarn audit` if that lockfile is present instead), `requirements.txt` → `pip-audit`, `Cargo.toml` → `cargo audit`, `go.mod` → `govulncheck ./...`. If more than one manifest is present, run each.57 - If the matching tool isn't installed, don't skip the checkpoint silently — say so explicitly in the report (e.g., "Update Dependencies: not run, `pip-audit` is not installed in this environment") rather than omitting it or treating it as a pass.58592. **Codebase Inspection:**60 - Run pattern-matching scans for credentials and secrets across the workspace.61 - Trace authentication workflows, route protection middleware, and database queries.62 - Audit response headers and application settings.63643. **Report Generation:**65 - Group findings by severity (Critical, High, Medium, Low).66 - Provide concrete code references (`file_path:line_number`).67 - Deliver actionable code patches and remediation commands for every identified vulnerability.6869---7071## 📋 Output Format7273Format the audit output using the following markdown structure:7475```markdown76# 🛡️ Security Audit Findings7778## Executive Summary79- **Total Issues Found:** X80- **Risk Breakdown:** 🔴 Critical: A | 🟠 High: B | 🟡 Medium: C | 🟢 Low: D8182---8384## 🔴 Critical & High Vulnerabilities8586### 1. [Vulnerability Title]87- **Category:** [e.g., Secrets Exposure / Module 2]88- **File:** `path/to/file.ext:42`89- **Impact:** [Brief description of real-world exploitation risk]90- **Current Code:**91 ```language92 // Problematic snippet93 ```94- **Remediation:**95 ```language96 // Corrected snippet97 ```98- **Remediation Command** (if applicable): `npm install package@latest`99100*(Repeat per Critical/High finding.)*101102---103104## 🟡 Medium & 🟢 Low Vulnerabilities105106### N. [Finding Title]107- **Category:** [Module reference]108- **File:** `path/to/file.ext:line`109- **Impact:** [Brief description]110- **Recommendation:** [Concrete fix, one or two lines]111112*(Repeat per Medium/Low finding. These may be listed more tersely than Critical/High.)*113114---115116## ✅ Passed Checks117118List checkpoints (by number, 1–19) that were inspected and found compliant, so the report shows full coverage rather than only problems.119120---121122## 📊 Risk Matrix123124| # | Checkpoint | Module | Status | Severity |125|---|---|---|---|---|126| 1 | Remove Unused Packages | 1 | ⚠️ Issue | Low |127| 2 | Update Dependencies | 1 | ✅ Pass | — |128| … | … | … | … | … |129130---131132## 🧭 Next Steps133134Ordered remediation checklist, Critical first, with the estimated effort for each (e.g., "single-line fix" vs. "requires design change").135```136137---138139## ⚠️ Ground Rules140141- **Never fabricate a finding.** Every reported issue must cite a real file and line; if a checkpoint cannot be verified (no test runner, no lockfile, etc.), say so in Passed Checks / a "Not Applicable" note rather than guessing.142- **Never auto-apply fixes without being asked.** This skill reports and proposes remediation; it does not silently rewrite auth, database, or payment code. Ask before editing anything security-critical.143- **Read secrets, never print them.** When Module 2 checks turn up a real credential, report its location and redact the value in the report itself.144- **Prefer the project's existing tools.** Use whatever audit/lint tooling the repo already has configured (`npm audit`, `pip-audit`, existing ESLint security rules) before reaching for an external scanner.