Security
Purpose
Find and fix vulnerability classes before attackers do, and keep secrets and
dependencies under control. The skill condenses the legacy audit taxonomy into a
repeatable pass: classify findings by CWE/OWASP category, fix in priority order, and
enforce secure-by-default patterns (validation at boundaries, no hardcoded secrets,
scanned dependencies).
When to Use / When NOT to Use
Use when:
- A security review is requested for code, an endpoint, or a service ("is this
secure?", "security review before launch").
- Handling secrets, tokens, credentials, or PII in any component.
- A CVE appears in a dependency and triage is needed.
Do NOT use when:
- The request is a general correctness review — use
code-quality/code-review.
- The request is SAST tooling setup — use
static-analysis (this skill consumes its
findings).
- An incident is already running — switch to
incident-response immediately.
Prerequisites & Assumptions
govulncheck (Go), pip-audit/uv audit (Python), OWASP dependency-check or
nancy (Java/Gradle) run in CI.
- Secrets are managed via environment/secrets manager (Vault, cloud secret store);
CI uses OIDC federation over long-lived keys.
- CVSS v3.1 severity bands: Critical ≥ 9.0, High ≥ 7.0, Medium ≥ 4.0, Low < 4.0.
Step-by-Step Workflow
- Enumerate the surface — list entry points (HTTP handlers, RPC methods,
CLI flags, file parsers) and trust boundaries; every entry point is untrusted
until validated.
- Scan the taxonomy — check each OWASP category below against the surface;
record findings as
| file | CWE | OWASP | severity | description |.
- Rank and fix in priority order — RCE > data breach > auth bypass >
information disclosure > DoS; one fix per change, each with a regression test.
- Run the dependency pass —
govulncheck ./... / pip-audit /
dependency-check; upgrade to the minimum safe version, pin, and record the CVE
in the changelog.
- Verify — re-run SAST and the scanners; confirm zero new findings and that
fixes did not break the threat model (e.g. authorization still enforced).
Vulnerability taxonomy (OWASP 2021 → check items)
| # |
Category |
Key checks |
| A01 |
Broken access control |
Per-object authz (IDOR), path traversal, missing role checks |
| A02 |
Cryptographic failures |
No MD5/SHA-1/DES, AES-GCM or ChaCha20-Poly1305, Argon2id/bcrypt (cost ≥ 12) for passwords, crypto/rand only |
| A03 |
Injection |
Parameterized SQL, no exec.Command with user input, template auto-escape, log injection |
| A05 |
Misconfiguration |
CORS not * on authed routes, debug/pprof off in prod, security headers, TLS 1.2+ |
| A06 |
Vulnerable dependencies |
Scanners in CI, CVE burn-down, transitive deps audited |
| A07 |
Authn failures |
No hardcoded creds, CSRF on state changes, rate limiting/lockout, JWT alg pinned |
| A08 |
Data integrity |
Bounded deserialization, http.MaxBytesReader, no untyped JSON into domain objects |
| A09 |
Logging failures |
No secrets/PII in logs, audit events for auth/authz/data changes, errors not leaked to clients |
| A10 |
SSRF |
Allowlist egress URLs, block metadata/file schemes, no blind redirects |
Enterprise Rules & Standards (MUST / MUST NOT)
- MUST validate and normalize all external input at the boundary; reject by
default (allowlists over denylists).
- MUST source secrets from environment or a secrets manager; scan repos with
gitleaks/trufflehog in CI; a leaked credential is revoked immediately, not just
removed.
- MUST enforce authorization per object (ownership checks), not just per route.
- MUST use parameterized queries and prepared statements everywhere.
- MUST use
crypto/rand for security values and Argon2id or bcrypt (cost ≥ 12)
for passwords; AES-GCM/ChaCha20-Poly1305 for encryption.
- MUST run dependency scanners as blocking CI gates; Critical/High CVEs block
release.
- MUST NOT use
math/rand for tokens, InsecureSkipVerify: true in production,
or return internal error details (stack traces, SQL) to clients.
- MUST NOT log secrets, full tokens, or PII; redact at the logging layer (see
observability).
Examples
Good — parameterized query + per-object authz (Go):
func (s *Store) Order(ctx context.Context, userID, orderID string) (Order, error) {
row := s.db.QueryRowContext(ctx,
`SELECT id, total, status FROM orders WHERE id = $1 AND user_id = $2`,
orderID, userID) // parameterized + ownership in the query
var o Order
if err := row.Scan(&o.ID, &o.Total, &o.Status); err != nil {
if errors.Is(err, sql.ErrNoRows) {
return Order{}, ErrOrderNotFound // sanitized: no existence leak to others
}
return Order{}, fmt.Errorf("store order: %w", err)
}
return o, nil
}
Bad — string-built SQL and missing ownership check:
q := fmt.Sprintf("SELECT * FROM orders WHERE id = '%s'", r.URL.Query().Get("id"))
rows, _ := db.Query(q) // SQL injection + IDOR + swallowed error
Why it fails: CWE-89 injection via the id parameter, CWE-639 IDOR because any
authenticated user can read any order, and the ignored error hides both.
Dependency triage (good):
CVE-2026-1234 (CVSS 8.1) in github.com/golang-jwt/jwt/v4 < 4.5.2
→ upgrade to v4.5.2 (go get github.com/golang-jwt/jwt/v4@v4.5.2), pin, note in changelog.
Checklist
Common Pitfalls
- Route-level authz confusion — "the router checks the token" ≠ "the user owns
the object"; always check both layers.
- Secrets in test fixtures — real credentials copied into tests; rotate and use
synthetic values.
- Scanner fatigue — ignoring reports until they're wallpaper; baseline +
burn-down (see
static-analysis) keeps signal high.
- Crypto DIY — rolling custom MAC/encryption; use the standard library
constructions only.
References
1---2name: security3description: 'Audits and hardens code against the OWASP Top 10 — input validation, authn/authz, secrets management, cryptography, and dependency scanning with CWE mapping. Trigger with "security review", "is this endpoint secure", "scan our dependencies", or "where do we store this secret".'4metadata:5 source: https://skillmd.com/skills/pnguyen215/security6---78# Security910## Purpose1112Find and fix vulnerability classes before attackers do, and keep secrets and13dependencies under control. The skill condenses the legacy audit taxonomy into a14repeatable pass: classify findings by CWE/OWASP category, fix in priority order, and15enforce secure-by-default patterns (validation at boundaries, no hardcoded secrets,16scanned dependencies).1718## When to Use / When NOT to Use1920Use when:2122- A security review is requested for code, an endpoint, or a service ("is this23 secure?", "security review before launch").24- Handling secrets, tokens, credentials, or PII in any component.25- A CVE appears in a dependency and triage is needed.2627Do NOT use when:2829- The request is a general correctness review — use `code-quality/code-review`.30- The request is SAST tooling setup — use `static-analysis` (this skill consumes its31 findings).32- An incident is already running — switch to `incident-response` immediately.3334## Prerequisites & Assumptions3536- `govulncheck` (Go), `pip-audit`/`uv audit` (Python), OWASP dependency-check or37 `nancy` (Java/Gradle) run in CI.38- Secrets are managed via environment/secrets manager (Vault, cloud secret store);39 CI uses OIDC federation over long-lived keys.40- CVSS v3.1 severity bands: Critical ≥ 9.0, High ≥ 7.0, Medium ≥ 4.0, Low < 4.0.4142## Step-by-Step Workflow43441. **Enumerate the surface** — list entry points (HTTP handlers, RPC methods,45 CLI flags, file parsers) and trust boundaries; every entry point is untrusted46 until validated.472. **Scan the taxonomy** — check each OWASP category below against the surface;48 record findings as `| file | CWE | OWASP | severity | description |`.493. **Rank and fix in priority order** — RCE > data breach > auth bypass >50 information disclosure > DoS; one fix per change, each with a regression test.514. **Run the dependency pass** — `govulncheck ./...` / `pip-audit` /52 dependency-check; upgrade to the minimum safe version, pin, and record the CVE53 in the changelog.545. **Verify** — re-run SAST and the scanners; confirm zero new findings and that55 fixes did not break the threat model (e.g. authorization still enforced).5657### Vulnerability taxonomy (OWASP 2021 → check items)5859| # | Category | Key checks |60| --- | ----------------------- | ------------------------------------------------------------------------------------------------------------- |61| A01 | Broken access control | Per-object authz (IDOR), path traversal, missing role checks |62| A02 | Cryptographic failures | No MD5/SHA-1/DES, AES-GCM or ChaCha20-Poly1305, Argon2id/bcrypt (cost ≥ 12) for passwords, `crypto/rand` only |63| A03 | Injection | Parameterized SQL, no `exec.Command` with user input, template auto-escape, log injection |64| A05 | Misconfiguration | CORS not `*` on authed routes, debug/pprof off in prod, security headers, TLS 1.2+ |65| A06 | Vulnerable dependencies | Scanners in CI, CVE burn-down, transitive deps audited |66| A07 | Authn failures | No hardcoded creds, CSRF on state changes, rate limiting/lockout, JWT `alg` pinned |67| A08 | Data integrity | Bounded deserialization, `http.MaxBytesReader`, no untyped JSON into domain objects |68| A09 | Logging failures | No secrets/PII in logs, audit events for auth/authz/data changes, errors not leaked to clients |69| A10 | SSRF | Allowlist egress URLs, block metadata/file schemes, no blind redirects |7071## Enterprise Rules & Standards (MUST / MUST NOT)7273- **MUST** validate and normalize all external input at the boundary; reject by74 default (allowlists over denylists).75- **MUST** source secrets from environment or a secrets manager; scan repos with76 gitleaks/trufflehog in CI; a leaked credential is revoked immediately, not just77 removed.78- **MUST** enforce authorization per object (ownership checks), not just per route.79- **MUST** use parameterized queries and prepared statements everywhere.80- **MUST** use `crypto/rand` for security values and Argon2id or bcrypt (cost ≥ 12)81 for passwords; AES-GCM/ChaCha20-Poly1305 for encryption.82- **MUST** run dependency scanners as blocking CI gates; Critical/High CVEs block83 release.84- **MUST NOT** use `math/rand` for tokens, `InsecureSkipVerify: true` in production,85 or return internal error details (stack traces, SQL) to clients.86- **MUST NOT** log secrets, full tokens, or PII; redact at the logging layer (see87 `observability`).8889## Examples9091Good — parameterized query + per-object authz (Go):9293```go94func (s *Store) Order(ctx context.Context, userID, orderID string) (Order, error) {95 row := s.db.QueryRowContext(ctx,96 `SELECT id, total, status FROM orders WHERE id = $1 AND user_id = $2`,97 orderID, userID) // parameterized + ownership in the query98 var o Order99 if err := row.Scan(&o.ID, &o.Total, &o.Status); err != nil {100 if errors.Is(err, sql.ErrNoRows) {101 return Order{}, ErrOrderNotFound // sanitized: no existence leak to others102 }103 return Order{}, fmt.Errorf("store order: %w", err)104 }105 return o, nil106}107```108109Bad — string-built SQL and missing ownership check:110111```go112q := fmt.Sprintf("SELECT * FROM orders WHERE id = '%s'", r.URL.Query().Get("id"))113rows, _ := db.Query(q) // SQL injection + IDOR + swallowed error114```115116Why it fails: CWE-89 injection via the `id` parameter, CWE-639 IDOR because any117authenticated user can read any order, and the ignored error hides both.118119Dependency triage (good):120121```text122CVE-2026-1234 (CVSS 8.1) in github.com/golang-jwt/jwt/v4 < 4.5.2123→ upgrade to v4.5.2 (go get github.com/golang-jwt/jwt/v4@v4.5.2), pin, note in changelog.124```125126## Checklist127128- [ ] Every entry point validates input against an allowlist schema.129- [ ] Per-object authorization enforced; IDOR probes included in tests.130- [ ] No secrets in code, config files, or logs; scanner (gitleaks) passes.131- [ ] `crypto/rand` only; password hashing Argon2id/bcrypt ≥ cost 12.132- [ ] Dependency scanners green; no open Critical/High CVEs.133- [ ] Security headers and TLS 1.2+ verified on all HTTP endpoints.134- [ ] Error responses sanitized; audit events emitted for auth/authz/data changes.135136## Common Pitfalls137138- **Route-level authz confusion** — "the router checks the token" ≠ "the user owns139 the object"; always check both layers.140- **Secrets in test fixtures** — real credentials copied into tests; rotate and use141 synthetic values.142- **Scanner fatigue** — ignoring reports until they're wallpaper; baseline +143 burn-down (see `static-analysis`) keeps signal high.144- **Crypto DIY** — rolling custom MAC/encryption; use the standard library145 constructions only.146147## References148149- OWASP Top 10 (2021): https://owasp.org/www-project-top-ten/150- OWASP Cheat Sheet Series: https://cheatsheetseries.owasp.org/151- CWE Top 25: https://cwe.mitre.org/top25/152- govulncheck: https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck153- NIST SP 800-53 Rev. 5: https://csrc.nist.gov/publications/detail/sp/800-53/rev-5/final