| name | security_audit |
| description | Performs a structured, multi-tier security audit optimized for detecting vulnerabilities, hardcoded secrets, and insecure patterns. Invoke when user requests security audit, vulnerability scan, or before deploying to production. |
SKILL: AI-Generated Security Audit
🎯 Objective
Execute a structured, multi-tier security audit specifically optimized for detecting vulnerabilities in AI-generated code. Prioritize critical threats (secrets exposure, injection flaws, broken auth) before lower-severity misconfigurations.
🧠 Core Principle: Critical First
Always evaluate from High-Risk (Secrets/Injection/Auth) to Medium/Low-Risk (Headers/Cookies/Config). If Stage 1 or 2 finds a FATAL issue, STOP the audit process and flag for immediate remediation. Do not waste compute auditing style when the foundation is insecure.
📊 Severity Legend
FATAL — Exploitable now or secret exposed. Stop and report immediately.
FAIL — Confirmed vulnerability. Block deployment until fixed.
WARN — Hardening gap or defense-in-depth weakness. Fix recommended.
PASS — Control verified present and effective.
N/A — Not applicable to this codebase (state why).
Map to CVSS-style bands when useful: FATAL ≈ Critical (9.0+), FAIL ≈ High (7.0+), WARN ≈ Medium/Low.
✅ Verification Discipline
Trace, don't guess. A control is only PASS when you followed the data from untrusted input to its sink, or confirmed the control is wired into the real request path. Note any area you could not reach (e.g., infra config outside the repo) as N/A with a reason rather than a false PASS.
🛠️ Execution Pipeline (Strict Order)
1. SECRETS_REVIEW (Hardcoded Credentials)
Goal: Zero live secrets in source, history, or bundles.
How to verify: grep high-signal patterns (AKIA[0-9A-Z]{16}, sk_live_, -----BEGIN .* PRIVATE KEY-----, eyJ JWT prefix); check git log -p and confirm .env is gitignored. A committed secret must be treated as compromised — rotation is part of the fix, not optional.
2. INJECTION_REVIEW (Input Validation & Sanitization)
Goal: No untrusted input reaches an interpreter unparameterized.
Example:
db.query(`SELECT * FROM users WHERE email = '${req.body.email}'`);
db.query('SELECT * FROM users WHERE email = ?', [req.body.email]);
3. AUTHENTICATION_REVIEW (Identity & Access Control)
Goal: Every sensitive path proves identity correctly.
Example:
const claims = jwt.decode(token);
const claims = jwt.verify(token, PUBLIC_KEY, { algorithms: ['RS256'], issuer, audience });
4. XSS_REVIEW (Cross-Site Scripting)
Goal: No untrusted data executes in a browser context.
Example:
el.innerHTML = comment.body;
el.textContent = comment.body;
5. CSRF_REVIEW (Cross-Site Request Forgery)
Goal: State-changing requests prove user intent.
6. CRYPTO_REVIEW (Encryption & Hashing)
Goal: Strong, current, correctly-applied primitives only.
Example:
const token = md5(Math.random().toString());
const token = crypto.randomBytes(32).toString('hex');
7. DATA_EXPOSURE_REVIEW (Sensitive Information Leakage)
Goal: Responses and logs reveal nothing sensitive.
8. DEPENDENCY_REVIEW (Third-Party Risks)
Goal: No known-vulnerable or malicious packages.
How to verify: Run the ecosystem scanner (npm audit, pip-audit, osv-scanner). For depth, hand off to the dependency_audit skill.
9. CONFIGURATION_REVIEW (Environment & Settings)
Goal: Safe defaults at the edge.
10. ACCESS_CONTROL_REVIEW (Authorization)
Goal: Authenticated ≠ authorized. Check object-level ownership.
Example:
app.get('/invoices/:id', auth, (req, res) => res.json(getInvoice(req.params.id)));
app.get('/invoices/:id', auth, (req, res) => res.json(getInvoice(req.params.id, req.user.id)));
📤 Output Directives
Use extreme brevity. Output an action-oriented checklist, one line per finding.
Format: [PASS/FAIL/WARN] - STAGE_NAME: Issue description & suggested fix.
Example output:
[FATAL] - SECRETS_REVIEW: AWS key AKIA... committed in config.js:7. Rotate key now; move to secrets manager.
[FAIL] - INJECTION_REVIEW: req.body.email concatenated into SQL in findUser(). Use parameterized query.
[FAIL] - ACCESS_CONTROL_REVIEW: GET /invoices/:id missing ownership check (IDOR). Scope query to req.user.id.
[WARN] - CONFIGURATION_REVIEW: CORS allows '*'. Restrict to known origins in production.
[PASS] - CRYPTO_REVIEW: Passwords hashed with bcrypt (cost 12), per-user salt.