Security audit

From tranhieutt/software_development_department · View interactive version

Security audit is an AI agent skill from the GitHub repository tranhieutt/software_development_department. Conducts a comprehensive security audit covering web application vulnerabilities, API security, OWASP Top 10, and security hardening recommendations. Use when auditing a codebase for security or when the user mentions security audit, penetration testing, or vulnerability scan.

How to use this skill

Skill file

Security Auditing Workflow

Systematic security review using static analysis tools available in the codebase.

Covers OWASP Top 10, secrets exposure, auth patterns, and dependency risk.

Phase 1: Reconnaissance — Map the Attack Surface

  1. Identify entry points — list all routes/controllers:

```bash

grep -rn "app\.\(get\|post\|put\|delete\|patch\)\|@app\.route\|router\." src/ --include="*.{js,ts,py}" | head -60

```

  1. Identify auth middleware — check which routes are protected:

```bash

grep -rn "auth\|middleware\|guard\|require_login\|jwt\|bearer" src/ -i --include="*.{js,ts,py}" | head -40

```

  1. Map external dependencies — check package files for known-risky libs:

```bash

cat package.json 2>/dev/null || cat requirements.txt 2>/dev/null || cat go.mod 2>/dev/null

```

  1. Note findings — list: total endpoints found, unprotected routes, third-party auth libs.

Phase 2: Secrets & Sensitive Data Exposure

  1. Scan for hardcoded secrets:

```bash

grep -rn "password\s=\s['\"][^'\"]\|api_key\s=\s['\"][^'\"]\|secret\s=\s['\"][^'\"]" src/ -i | grep -v ".example" | head -30

```

  1. Scan for tokens/keys in source:

```bash

grep -rEn "(sk-|AIza|AKIA|ghp_|xox[baprs]-)[A-Za-z0-9]+" src/ | head -20

```

  1. Check .env files are gitignored:

```bash

cat .gitignore | grep -i "\.env" ; ls -la .env* 2>/dev/null

```

  1. Check for secrets in logs:

```bash

grep -rn "console\.log.password\|logger.token\|print.*secret" src/ -i | head -20

```

Flag: any hardcoded credential or unignored .env file is a P0 finding.


Phase 3: Injection & Input Validation

  1. SQL injection risk — look for string concatenation in queries:

```bash

grep -rn "query.+\|execute.f\"\|raw.%s\|SELECT.\$\{" src/ --include="*.{js,ts,py}" | head -30

```

  1. Command injection risk — shell execution with user input:

```bash

grep -rn "exec(\|spawn(\|subprocess\|os\.system\|child_process" src/ --include="*.{js,ts,py}" | head -20

```

  1. XSS risk — unescaped HTML rendering:

```bash

grep -rn "innerHTML\|dangerouslySetInnerHTML\|v-html\|\.html(" src/ --include="*.{js,ts,jsx,tsx,vue}" | head -20

```

  1. Check for input validation middleware — is there a schema validator at boundaries?

```bash

grep -rn "joi\|zod\|yup\|pydantic\|cerberus\|marshmallow" src/ --include="*.{js,ts,py}" | head -10

```


Phase 4: Authentication & Authorization

  1. JWT / token handling — check for weak configs:

```bash

grep -rn "algorithm.HS256\|expiresIn\|verify\|decode" src/ --include=".{js,ts,py}" | head -20

```

  1. Password hashing — confirm bcrypt/argon2, not MD5/SHA1:

```bash

grep -rn "md5\|sha1\|hashSync\|bcrypt\|argon2\|pbkdf2" src/ -i --include="*.{js,ts,py}" | head -20

```

  1. CORS config — check for wildcard origins:

```bash

grep -rn "cors\|Access-Control-Allow-Origin\|\" src/ --include=".{js,ts,py}" | head -20

```

  1. Authorization checks — look for missing ownership checks in update/delete:

```bash

grep -rn "findById\|findOne\|get_object_or_404" src/ --include="*.{js,ts,py}" | head -20

```

Review each — does the handler verify resource.userId === req.user.id?


Phase 5: Security Headers & Config

  1. HTTP security headers — check if helmet/similar is configured:

```bash

grep -rn "helmet\|Content-Security-Policy\|X-Frame-Options\|Strict-Transport" src/ --include="*.{js,ts}" | head -10

```

  1. Rate limiting — check for brute-force protection on auth routes:

```bash

grep -rn "rateLimit\|throttle\|rate_limit\|slowDown" src/ --include="*.{js,ts,py}" | head -10

```

  1. HTTPS enforcement — check redirect config:

```bash

grep -rn "http://\|forceHttps\|redirectToHttps\|SECURE_SSL_REDIRECT" src/ --include="*.{js,ts,py}" | head -10

```


Phase 6: Report Findings

For each finding, record:

| Severity | Category | File:Line | Description | Remediation |

|----------|----------|-----------|-------------|-------------|

| P0 Critical | | | | |

| P1 High | | | | |

| P2 Medium | | | | |

| P3 Low / Info | | | | |

Severity guide:

Save report to docs/technical/security-audit-{YYYY-MM-DD}.md.


Security Checklist

OWASP Top 10

Protocol

Output

Deliver exactly:

Secure Coding Reference

When the audit finds a vulnerability and the fix requires hands-on secure

coding guidance, apply the following patterns inline (no separate skill needed).

Backend Secure Coding Patterns

Frontend Secure Coding Patterns

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.