Security Auditor
Use this skill to audit AI-generated code and human-written changes before they are merged or deployed. It focuses on application security, auth, data protection, secrets, dependency risk, infrastructure exposure, and exploitability.
This is different from skill-security-auditor, which audits AI skill packages before installation. Use security-auditor for product code and repository changes.
When to Use
- Reviewing AI-generated code for security flaws.
- Auditing pull requests that touch authentication, authorization, payments, user data, file upload, webhooks, secrets, infrastructure, or dependencies.
- Checking generated APIs, database queries, server actions, middleware, background jobs, or CI workflows.
- Validating that frontend changes do not expose privileged data or trust client-only checks.
- Investigating a suspected vulnerability or insecure pattern.
- Hardening code before release.
- Creating security regression tests for a fixed issue.
Skip When
- The target is an AI skill package rather than application code. Use
skill-security-auditor.
- The user requests a full formal penetration test, legal compliance certification, or production exploit attempt without authorization.
- The task is pure style review with no security relevance.
Core Capabilities
- Threat-model a change by assets, actors, trust boundaries, and abuse paths.
- Review code for OWASP-style issues and framework-specific security mistakes.
- Check authn/authz correctness beyond happy-path role checks.
- Detect secret leakage, unsafe logging, and sensitive data exposure.
- Review dependency and supply-chain risk.
- Inspect infrastructure and CI changes for privilege escalation or exposure.
- Produce actionable findings with severity, evidence, exploit path, and fix.
- Recommend tests that prevent recurrence.
Audit Sequence
Use this sequence for repository changes:
1. Identify changed files and security-sensitive surfaces.
2. Map trust boundaries and protected assets.
3. Review input validation, auth, data access, side effects, and error paths.
4. Scan for secrets and dangerous APIs.
5. Check dependencies, CI, and infrastructure exposure.
6. Confirm mitigations with tests or concrete reasoning.
7. Report only actionable findings with severity and evidence.
Threat Model Mini-Template
## Assets
- User data:
- Credentials/tokens:
- Money or quota:
- Admin capabilities:
## Actors
- Anonymous:
- Authenticated user:
- Tenant member:
- Admin:
- External service:
## Trust Boundaries
- Browser to API:
- API to database:
- Webhook provider to app:
- CI to cloud:
## Abuse Cases
- ...
High-Risk Surfaces
- Login, registration, password reset, MFA, SSO, sessions, cookies, and refresh tokens.
- Authorization middleware, RBAC, ABAC, tenant scoping, row-level security, and admin routes.
- File upload, image processing, archive extraction, document parsing, and media metadata.
- Webhooks, callbacks, OAuth redirects, and third-party integrations.
- Payment, billing, coupons, credits, usage limits, and subscription state.
- Search, filters, raw SQL, ORM query builders, GraphQL resolvers, and NoSQL queries.
- Server-side rendering, server actions, template rendering, markdown rendering, and HTML sanitization.
- Background jobs, queues, cron tasks, retries, idempotency, and event handlers.
- CI/CD workflows, deployment scripts, cloud roles, Kubernetes manifests, and Terraform.
Code Review Checks
- Input validation happens at the server trust boundary.
- Client-side validation is treated only as UX, never as authorization.
- Authorization checks use server-known identity and tenant context.
- Database queries cannot cross tenant boundaries.
- Direct object references are scoped to the current principal.
- Secrets are read from secret stores and never logged.
- Errors do not reveal tokens, stack traces, SQL, internal paths, or PII.
- Passwords and tokens are hashed or stored using approved primitives.
- Session cookies use
HttpOnly, Secure, appropriate SameSite, and bounded lifetime.
- CORS is explicit and does not allow credentials for arbitrary origins.
- File uploads validate type, size, extension, content, storage path, and serving mode.
- Webhooks verify signatures and timestamps before side effects.
- Mutating endpoints have CSRF protection where cookie auth is used.
- Rate limits protect login, password reset, OTP, invite, and expensive operations.
- Audit logs capture sensitive administrative changes.
Dangerous Patterns
eval(
new Function(
dangerouslySetInnerHTML
innerHTML =
child_process.exec
shell=True
pickle.loads
yaml.load(..., Loader=yaml.Loader)
SELECT ... ${userInput}
where: { tenantId: req.body.tenantId }
Access-Control-Allow-Origin: *
console.log(process.env
Treat these as prompts to inspect context. They are not automatically vulnerabilities, but they deserve evidence-based review.
Dependency and Supply-Chain Checks
- Lockfile changes match package manifest changes.
- New dependencies are necessary, maintained, and license-compatible.
- Install scripts are not introduced without review.
- Package names are checked for typosquatting.
- Dependency audit results are triaged by exploitability, not just count.
- Container base images are pinned and scanned.
- CI actions are pinned by SHA where risk warrants.
- Generated code does not vendor unknown binaries.
Infrastructure Checks
- Cloud roles use least privilege.
- Public buckets, databases, dashboards, queues, and admin panels are intentional.
- Security groups and ingress rules are narrowed.
- Kubernetes service accounts are scoped.
- Secrets are not placed in ConfigMaps, logs, artifacts, or build args.
- Terraform plans do not widen access unexpectedly.
- CI tokens are not available to untrusted fork pull requests.
- Production deploys require protected branch or environment controls.
Severity Model
- Critical: unauthenticated or low-privilege path to data breach, remote code execution, credential theft, payment abuse, or full tenant escape.
- High: authenticated but realistic path to privilege escalation, sensitive data exposure, stored XSS, SSRF to sensitive network, or destructive action.
- Medium: constrained vulnerability requiring unusual preconditions or limited data impact.
- Low: defense-in-depth issue, missing hardening, weak diagnostics, or minor information leak.
Finding Format
## Findings
- [High] path/to/file.ts:42 - Missing tenant scope in project lookup.
Evidence: The query uses `projectId` from params but does not constrain by `tenantId`.
Impact: Any authenticated user who guesses an id can read another tenant's project.
Fix: Add tenant scope from server session and add a regression test for cross-tenant access.
Verification Commands
Use the repo's existing tools first. Common examples:
npm audit --audit-level=high
pnpm audit --prod
pip-audit
semgrep scan --config p/owasp-top-ten
gitleaks detect --no-git
trivy fs .
Do not invent a clean result. If a tool is unavailable or noisy, report that clearly.
Security Regression Tests
For every confirmed vulnerability, recommend at least one test:
- Unauthorized user is denied.
- Wrong tenant is denied.
- Invalid signature is rejected.
- Malicious payload is escaped or sanitized.
- Dangerous file type is rejected.
- Duplicate webhook does not double-charge or double-apply state.
- Rate limit triggers after threshold.
Anti-Patterns
- Treating AI-generated code as safe because it compiles.
- Reporting generic "use HTTPS" findings without repository evidence.
- Trusting frontend role checks.
- Fixing auth by hiding UI controls while API remains open.
- Logging whole request bodies.
- Adding broad try/catch that hides security failures.
- Dismissing dependency issues without checking reachability.
- Running exploit attempts against systems without authorization.
Boundaries
This skill provides security review guidance, not legal certification. Stay within authorized local code, test systems, or user-approved targets. Do not exfiltrate secrets, exploit production systems, or provide offensive persistence instructions.
1---2name: security-auditor3description: Security audit workflow for AI-generated application code, APIs, infrastructure changes, dependencies, secrets, auth flows, and pull requests before they ship.4license: MIT5---6
7# Security Auditor
8
9Use this skill to audit AI-generated code and human-written changes before they are merged or deployed. It focuses on application security, auth, data protection, secrets, dependency risk, infrastructure exposure, and exploitability.
10
11This is different from `skill-security-auditor`, which audits AI skill packages before installation. Use `security-auditor` for product code and repository changes.
12
13## When to Use
14
15- Reviewing AI-generated code for security flaws.
16- Auditing pull requests that touch authentication, authorization, payments, user data, file upload, webhooks, secrets, infrastructure, or dependencies.
17- Checking generated APIs, database queries, server actions, middleware, background jobs, or CI workflows.
18- Validating that frontend changes do not expose privileged data or trust client-only checks.
19- Investigating a suspected vulnerability or insecure pattern.
20- Hardening code before release.
21- Creating security regression tests for a fixed issue.
22
23## Skip When
24
25- The target is an AI skill package rather than application code. Use `skill-security-auditor`.
26- The user requests a full formal penetration test, legal compliance certification, or production exploit attempt without authorization.
27- The task is pure style review with no security relevance.
28
29## Core Capabilities
30
311. Threat-model a change by assets, actors, trust boundaries, and abuse paths.
322. Review code for OWASP-style issues and framework-specific security mistakes.
333. Check authn/authz correctness beyond happy-path role checks.
344. Detect secret leakage, unsafe logging, and sensitive data exposure.
355. Review dependency and supply-chain risk.
366. Inspect infrastructure and CI changes for privilege escalation or exposure.
377. Produce actionable findings with severity, evidence, exploit path, and fix.
388. Recommend tests that prevent recurrence.
39
40## Audit Sequence
41
42Use this sequence for repository changes:
43
44```text
451. Identify changed files and security-sensitive surfaces.
462. Map trust boundaries and protected assets.
473. Review input validation, auth, data access, side effects, and error paths.
484. Scan for secrets and dangerous APIs.
495. Check dependencies, CI, and infrastructure exposure.
506. Confirm mitigations with tests or concrete reasoning.
517. Report only actionable findings with severity and evidence.
52```
53
54## Threat Model Mini-Template
55
56```markdown
57## Assets
58- User data:
59- Credentials/tokens:
60- Money or quota:
61- Admin capabilities:
62
63## Actors
64- Anonymous:
65- Authenticated user:
66- Tenant member:
67- Admin:
68- External service:
69
70## Trust Boundaries
71- Browser to API:
72- API to database:
73- Webhook provider to app:
74- CI to cloud:
75
76## Abuse Cases
77- ...
78```
79
80## High-Risk Surfaces
81
82- Login, registration, password reset, MFA, SSO, sessions, cookies, and refresh tokens.
83- Authorization middleware, RBAC, ABAC, tenant scoping, row-level security, and admin routes.
84- File upload, image processing, archive extraction, document parsing, and media metadata.
85- Webhooks, callbacks, OAuth redirects, and third-party integrations.
86- Payment, billing, coupons, credits, usage limits, and subscription state.
87- Search, filters, raw SQL, ORM query builders, GraphQL resolvers, and NoSQL queries.
88- Server-side rendering, server actions, template rendering, markdown rendering, and HTML sanitization.
89- Background jobs, queues, cron tasks, retries, idempotency, and event handlers.
90- CI/CD workflows, deployment scripts, cloud roles, Kubernetes manifests, and Terraform.
91
92## Code Review Checks
93
94- Input validation happens at the server trust boundary.
95- Client-side validation is treated only as UX, never as authorization.
96- Authorization checks use server-known identity and tenant context.
97- Database queries cannot cross tenant boundaries.
98- Direct object references are scoped to the current principal.
99- Secrets are read from secret stores and never logged.
100- Errors do not reveal tokens, stack traces, SQL, internal paths, or PII.
101- Passwords and tokens are hashed or stored using approved primitives.
102- Session cookies use `HttpOnly`, `Secure`, appropriate `SameSite`, and bounded lifetime.
103- CORS is explicit and does not allow credentials for arbitrary origins.
104- File uploads validate type, size, extension, content, storage path, and serving mode.
105- Webhooks verify signatures and timestamps before side effects.
106- Mutating endpoints have CSRF protection where cookie auth is used.
107- Rate limits protect login, password reset, OTP, invite, and expensive operations.
108- Audit logs capture sensitive administrative changes.
109
110## Dangerous Patterns
111
112```text
113eval(
114new Function(
115dangerouslySetInnerHTML
116innerHTML =
117child_process.exec
118shell=True
119pickle.loads
120yaml.load(..., Loader=yaml.Loader)
121SELECT ... ${userInput}
122where: { tenantId: req.body.tenantId }
123Access-Control-Allow-Origin: *
124console.log(process.env
125```
126
127Treat these as prompts to inspect context. They are not automatically vulnerabilities, but they deserve evidence-based review.
128
129## Dependency and Supply-Chain Checks
130
131- Lockfile changes match package manifest changes.
132- New dependencies are necessary, maintained, and license-compatible.
133- Install scripts are not introduced without review.
134- Package names are checked for typosquatting.
135- Dependency audit results are triaged by exploitability, not just count.
136- Container base images are pinned and scanned.
137- CI actions are pinned by SHA where risk warrants.
138- Generated code does not vendor unknown binaries.
139
140## Infrastructure Checks
141
142- Cloud roles use least privilege.
143- Public buckets, databases, dashboards, queues, and admin panels are intentional.
144- Security groups and ingress rules are narrowed.
145- Kubernetes service accounts are scoped.
146- Secrets are not placed in ConfigMaps, logs, artifacts, or build args.
147- Terraform plans do not widen access unexpectedly.
148- CI tokens are not available to untrusted fork pull requests.
149- Production deploys require protected branch or environment controls.
150
151## Severity Model
152
153- Critical: unauthenticated or low-privilege path to data breach, remote code execution, credential theft, payment abuse, or full tenant escape.
154- High: authenticated but realistic path to privilege escalation, sensitive data exposure, stored XSS, SSRF to sensitive network, or destructive action.
155- Medium: constrained vulnerability requiring unusual preconditions or limited data impact.
156- Low: defense-in-depth issue, missing hardening, weak diagnostics, or minor information leak.
157
158## Finding Format
159
160```markdown
161## Findings
162- [High] path/to/file.ts:42 - Missing tenant scope in project lookup.
163 Evidence: The query uses `projectId` from params but does not constrain by `tenantId`.
164 Impact: Any authenticated user who guesses an id can read another tenant's project.
165 Fix: Add tenant scope from server session and add a regression test for cross-tenant access.
166```
167
168## Verification Commands
169
170Use the repo's existing tools first. Common examples:
171
172```bash
173npm audit --audit-level=high
174pnpm audit --prod
175pip-audit
176semgrep scan --config p/owasp-top-ten
177gitleaks detect --no-git
178trivy fs .
179```
180
181Do not invent a clean result. If a tool is unavailable or noisy, report that clearly.
182
183## Security Regression Tests
184
185For every confirmed vulnerability, recommend at least one test:
186
187- Unauthorized user is denied.
188- Wrong tenant is denied.
189- Invalid signature is rejected.
190- Malicious payload is escaped or sanitized.
191- Dangerous file type is rejected.
192- Duplicate webhook does not double-charge or double-apply state.
193- Rate limit triggers after threshold.
194
195## Anti-Patterns
196
197- Treating AI-generated code as safe because it compiles.
198- Reporting generic "use HTTPS" findings without repository evidence.
199- Trusting frontend role checks.
200- Fixing auth by hiding UI controls while API remains open.
201- Logging whole request bodies.
202- Adding broad try/catch that hides security failures.
203- Dismissing dependency issues without checking reachability.
204- Running exploit attempts against systems without authorization.
205
206## Boundaries
207
208This skill provides security review guidance, not legal certification. Stay within authorized local code, test systems, or user-approved targets. Do not exfiltrate secrets, exploit production systems, or provide offensive persistence instructions.