| name | security-hardening |
| description | Full security audit and hardening workflow covering OWASP Top 10, dependency scanning, secrets management, and infrastructure security. Use when auditing security, hardening an application, or responding to vulnerability reports. Triggers on: security, harden, vulnerability, OWASP, audit, CVE, penetration. |
Security Hardening Skill
Full security audit and hardening pipeline. Covers threat modeling, OWASP Top 10 compliance, dependency scanning, secrets management, auth review, input validation, infrastructure hardening, and verified remediation.
References
Pipeline
Phase 1: Threat Modeling
Identify the application's attack surface before auditing code.
- Map all entry points — HTTP endpoints, WebSocket handlers, CLI commands, message consumers, file upload paths
- Identify trust boundaries — where untrusted data crosses into trusted zones (user input → server, server → database, service → service)
- Document data flows — trace sensitive data (credentials, PII, tokens, payment info) from ingress to storage to egress
- Enumerate threat actors — anonymous users, authenticated users, internal services, supply chain (dependencies), infrastructure operators
- Classify assets by sensitivity — public, internal, confidential, restricted
- Produce a threat model summary: entry points, trust boundaries, data classification, and identified risks ranked by likelihood × impact
Phase 2: OWASP Top 10 Audit
Systematically check every OWASP Top 10 2021 category against the codebase. Use the full checklist in references/owasp-checklist.md.
- For each of the 10 categories (A01–A10), check every item in the checklist
- For each finding, record: category, file, line, severity (CRITICAL/HIGH/MEDIUM/LOW), description, and recommended fix
- Cross-reference with the threat model — findings on high-sensitivity data flows escalate one severity level
- Flag any category with zero findings as "reviewed — no issues found" (not "skipped")
- Append all findings to
docs/SECURITY_REPORT.md
Phase 3: Dependency Scanning
Audit all direct and transitive dependencies for known vulnerabilities.
- Identify the package manager(s) in use (npm, pip, cargo, go modules, NuGet, Maven, etc.)
- Run or simulate a dependency audit — check for known CVEs in all dependencies
- Flag outdated packages — any dependency more than 2 major versions behind or with known CVEs
- Check license compliance — flag copyleft licenses (GPL, AGPL) in proprietary projects, flag unknown licenses
- Identify unused dependencies — installed but never imported
- Record findings with: package name, current version, latest version, CVE IDs (if any), severity, and recommended action (update/replace/remove)
Phase 4: Secrets Audit
Scan for hardcoded secrets and verify secrets management practices.
- Search the entire codebase for hardcoded secrets — API keys, passwords, tokens, connection strings, private keys, JWTs
- Check patterns:
password=, secret=, api_key=, token=, -----BEGIN, base64-encoded strings in source, .env files committed to git
- Verify
.gitignore includes: .env, .env.*, *.pem, *.key, secrets directories
- Check git history for previously committed secrets (even if currently removed)
- Verify secrets are loaded from environment variables or a secrets manager — never from source code
- Check secret rotation policies — are there expiration dates, rotation mechanisms, or revocation procedures?
- Flag any finding as CRITICAL — hardcoded secrets are always critical severity
Phase 5: Authentication & Authorization
Audit auth flows, session management, and access control.
- Review authentication mechanisms — password hashing algorithm (bcrypt/argon2/scrypt, NOT MD5/SHA1), multi-factor auth support, account lockout after failed attempts
- Check session management — secure cookie flags (HttpOnly, Secure, SameSite), session expiration, session invalidation on logout, token rotation
- Audit authorization — verify access control checks on every protected endpoint, check for IDOR vulnerabilities, verify RBAC/ABAC implementation
- Check password policies — minimum length (≥12), complexity requirements, breach database checking
- Review JWT handling (if applicable) — algorithm validation (reject
none), expiration enforcement, audience/issuer validation, key management
- Verify OAuth/OIDC flows (if applicable) — state parameter usage, PKCE for public clients, redirect URI validation
Phase 6: Input Validation
Check all user input paths for proper sanitization and injection prevention.
- Trace every path where user input enters the system (request params, headers, body, file uploads, URL paths)
- Check for SQL injection — verify parameterized queries or ORM usage everywhere, no string concatenation in queries
- Check for XSS — verify output encoding in templates, CSP headers, no
innerHTML/dangerouslySetInnerHTML with user data
- Check for command injection — verify no shell command construction with user input, use parameterized APIs
- Check for path traversal — verify file path inputs are sanitized, no
../ sequences reach the filesystem
- Check for SSRF — verify URL inputs are validated against allowlists, no internal network access from user-supplied URLs
- Verify file upload security — type validation (not just extension), size limits, storage outside webroot, filename sanitization
- Check for mass assignment — verify request body fields are explicitly allowlisted, not blindly bound to models
Phase 7: Infrastructure Security
Audit HTTP headers, TLS configuration, CORS policy, and rate limiting.
- Check all security headers per references/security-headers.md — CSP, HSTS, X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy, COEP, COOP, CORP
- Verify TLS configuration — TLS 1.2+ only, strong cipher suites, HSTS with
includeSubDomains and preload
- Audit CORS policy — no wildcard (
*) origins in production, credentials mode properly configured, allowed methods/headers restricted
- Check rate limiting — authentication endpoints, API endpoints, file upload endpoints, password reset
- Verify error handling — no stack traces or internal details in production error responses, generic error messages for auth failures
- Check logging — security events logged (failed auth, access denied, input validation failures), no sensitive data in logs (passwords, tokens, PII)
- Verify cookie security — Secure flag, HttpOnly flag, SameSite attribute, appropriate domain/path scope
Phase 8: Remediation Plan
Prioritize all findings and create an actionable fix list.
- Aggregate all findings from Phases 2–7
- Deduplicate — merge findings that share the same root cause
- Assign final severity: CRITICAL (actively exploitable, data breach risk), HIGH (exploitable with effort), MEDIUM (defense-in-depth gap), LOW (best practice improvement)
- Sort by severity, then by blast radius (number of affected endpoints/files)
- For each finding, provide:
- One-line description
- Affected file(s) and line(s)
- Specific remediation steps (code-level, not generic advice)
- Estimated effort (trivial/small/medium/large)
- Group into implementation batches: Batch 1 = all CRITICAL, Batch 2 = all HIGH, Batch 3 = MEDIUM + LOW
- Write the plan to
docs/SECURITY_REPORT.md under a ## Remediation Plan section
Phase 9: Verification
Re-scan after fixes to confirm resolution.
- After Workers implement fixes from the remediation plan, re-run the relevant audit phases
- For each fixed finding, verify:
- The specific vulnerability is no longer present
- The fix did not introduce new vulnerabilities
- Existing tests still pass (no regressions)
- Update
docs/SECURITY_REPORT.md — mark resolved findings as ✅, note verification date
- Any finding that persists after a fix attempt escalates one severity level
- Produce a verification summary: total findings, resolved, remaining, new (if any)
Severity Definitions
| Severity | Definition | SLA |
|---|
| CRITICAL | Actively exploitable, immediate data breach or system compromise risk | Fix before merge |
| HIGH | Exploitable with moderate effort or insider knowledge | Fix within current sprint |
| MEDIUM | Defense-in-depth gap, requires chained vulnerabilities to exploit | Fix within next sprint |
| LOW | Best practice improvement, minimal direct risk | Track in backlog |
Output
All findings are appended to docs/SECURITY_REPORT.md using the project's report template format. The Security Agent owns this file. Each audit session adds a dated section with findings, remediation plan, and verification status.