|
| 1 | +# Security Checklist |
| 2 | + |
| 3 | +Quick reference for application security. Stack-agnostic — applies to Rust, Python, Go, TypeScript, and beyond. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Pre-Commit Checks](#pre-commit-checks) |
| 8 | +- [Authentication](#authentication) |
| 9 | +- [Authorization](#authorization) |
| 10 | +- [Input Validation](#input-validation) |
| 11 | +- [Cryptography](#cryptography) |
| 12 | +- [Data Protection](#data-protection) |
| 13 | +- [Dependency Security](#dependency-security) |
| 14 | +- [Error Handling](#error-handling) |
| 15 | +- [Infrastructure](#infrastructure) |
| 16 | +- [OWASP Top 10 Quick Reference](#owasp-top-10-quick-reference) |
| 17 | + |
| 18 | +## Pre-Commit Checks |
| 19 | + |
| 20 | +- [ ] No secrets in code (passwords, API keys, tokens, private keys) |
| 21 | +- [ ] `.gitignore` covers: `.env`, `*.pem`, `*.key`, `credentials.*` |
| 22 | +- [ ] `.env.example` uses placeholder values only |
| 23 | +- [ ] No hardcoded connection strings or endpoints |
| 24 | +- [ ] Secret scanning enabled in CI (e.g., `gitleaks`, `trufflehog`) |
| 25 | + |
| 26 | +## Authentication |
| 27 | + |
| 28 | +- [ ] Passwords hashed with bcrypt (>=12 rounds), scrypt, or argon2 |
| 29 | +- [ ] Session tokens are cryptographically random (>=256 bits) |
| 30 | +- [ ] Session expiration configured with reasonable max-age |
| 31 | +- [ ] Rate limiting on login endpoints (<=10 attempts per 15 minutes) |
| 32 | +- [ ] Password reset tokens: time-limited (<=1 hour), single-use |
| 33 | +- [ ] Account lockout after repeated failures (with notification) |
| 34 | +- [ ] MFA supported for sensitive operations |
| 35 | + |
| 36 | +## Authorization |
| 37 | + |
| 38 | +- [ ] Every protected endpoint checks authentication first |
| 39 | +- [ ] Every resource access checks ownership or role (prevents IDOR) |
| 40 | +- [ ] Admin endpoints require admin role verification |
| 41 | +- [ ] API keys/tokens scoped to minimum necessary permissions |
| 42 | +- [ ] JWT tokens validated: signature, expiration, issuer, audience |
| 43 | +- [ ] Default deny: new endpoints are protected unless explicitly public |
| 44 | +- [ ] Service-to-service calls authenticated (mTLS, signed tokens) |
| 45 | + |
| 46 | +## Input Validation |
| 47 | + |
| 48 | +- [ ] All user input validated at system boundaries |
| 49 | +- [ ] Validation uses allowlists, not denylists |
| 50 | +- [ ] String lengths constrained (min/max) |
| 51 | +- [ ] Numeric ranges validated and bounds-checked |
| 52 | +- [ ] File uploads: type restricted, size limited, content verified |
| 53 | +- [ ] SQL queries parameterized (no string concatenation) |
| 54 | +- [ ] Output encoded/escaped for context (HTML, SQL, shell, URLs) |
| 55 | +- [ ] URLs validated before redirect (prevent open redirect) |
| 56 | +- [ ] Deserialization restricted to expected types (no arbitrary object creation) |
| 57 | + |
| 58 | +## Cryptography |
| 59 | + |
| 60 | +- [ ] TLS 1.2+ for all network communication |
| 61 | +- [ ] No custom crypto implementations (use audited libraries) |
| 62 | +- [ ] Symmetric encryption: AES-256-GCM or ChaCha20-Poly1305 |
| 63 | +- [ ] Asymmetric: RSA >=2048 bits or Ed25519 |
| 64 | +- [ ] Random values from CSPRNG, not `rand()` or `Math.random()` |
| 65 | +- [ ] Keys rotated on schedule and on compromise |
| 66 | + |
| 67 | +| Language | Crypto Library | CSPRNG | |
| 68 | +|----------|---------------|--------| |
| 69 | +| Rust | `ring`, `rustls` | `rand::rngs::OsRng` | |
| 70 | +| Python | `cryptography` | `secrets` module | |
| 71 | +| Go | `crypto/*` stdlib | `crypto/rand` | |
| 72 | +| TypeScript | `crypto` (Node) | `crypto.randomBytes` | |
| 73 | + |
| 74 | +## Data Protection |
| 75 | + |
| 76 | +- [ ] Sensitive fields excluded from API responses (password hashes, tokens) |
| 77 | +- [ ] Sensitive data not logged (passwords, tokens, PII) |
| 78 | +- [ ] PII encrypted at rest (if required by regulation) |
| 79 | +- [ ] Database backups encrypted |
| 80 | +- [ ] Data retention policy defined and enforced |
| 81 | +- [ ] Personally identifiable data deletable on request |
| 82 | + |
| 83 | +## Dependency Security |
| 84 | + |
| 85 | +- [ ] Dependencies audited regularly for known vulnerabilities |
| 86 | +- [ ] Lockfile committed and used in CI (reproducible builds) |
| 87 | +- [ ] Automated alerts for vulnerable dependencies enabled |
| 88 | +- [ ] Minimal dependency policy (fewer deps = smaller attack surface) |
| 89 | + |
| 90 | +| Language | Audit Command | |
| 91 | +|----------|--------------| |
| 92 | +| Rust | `cargo audit` | |
| 93 | +| Python | `pip-audit`, `safety check` | |
| 94 | +| Go | `govulncheck ./...` | |
| 95 | +| TypeScript | `npm audit`, `yarn audit` | |
| 96 | + |
| 97 | +## Error Handling |
| 98 | + |
| 99 | +- [ ] Production errors are generic (no stack traces, SQL, or internals) |
| 100 | +- [ ] Errors logged server-side with correlation IDs |
| 101 | +- [ ] Error messages do not reveal user existence (login/signup) |
| 102 | +- [ ] Panic/crash recovery does not expose sensitive state |
| 103 | +- [ ] Rate-limited error responses (prevent enumeration attacks) |
| 104 | + |
| 105 | +## Infrastructure |
| 106 | + |
| 107 | +- [ ] HTTPS enforced (redirect HTTP to HTTPS) |
| 108 | +- [ ] Security headers set (CSP, HSTS, X-Content-Type-Options, X-Frame-Options) |
| 109 | +- [ ] CORS restricted to known origins (never `*` in production) |
| 110 | +- [ ] Containers run as non-root user |
| 111 | +- [ ] Network segmentation between services and databases |
| 112 | +- [ ] Secrets managed via vault/KMS, not environment variables in code |
| 113 | + |
| 114 | +## OWASP Top 10 Quick Reference |
| 115 | + |
| 116 | +| # | Vulnerability | Prevention | |
| 117 | +|---|---|---| |
| 118 | +| 1 | Broken Access Control | Auth checks on every endpoint, ownership verification | |
| 119 | +| 2 | Cryptographic Failures | HTTPS, strong hashing, no secrets in code | |
| 120 | +| 3 | Injection | Parameterized queries, input validation | |
| 121 | +| 4 | Insecure Design | Threat modeling, spec-driven development | |
| 122 | +| 5 | Security Misconfiguration | Security headers, minimal permissions, audit deps | |
| 123 | +| 6 | Vulnerable Components | Audit deps, keep updated, minimize dependencies | |
| 124 | +| 7 | Auth Failures | Strong passwords, rate limiting, session management | |
| 125 | +| 8 | Data Integrity Failures | Verify updates/dependencies, signed artifacts | |
| 126 | +| 9 | Logging Failures | Log security events, don't log secrets | |
| 127 | +| 10 | SSRF | Validate/allowlist URLs, restrict outbound requests | |
0 commit comments