Security And Hardening

Hardens code against vulnerabilities. Use when handling user input, authentication, data storage, or external integrations. Use when building any feature that accepts untrusted data, manages user sessions, or interacts with third-party services.

The Standard: every external input is hostile, every secret is sacred, every authorization check is mandatory.
Always do
No exceptions
  • ·Validate all external input at the boundary
  • ·Parameterize all DB queries (no string concat)
  • ·Encode output to prevent XSS
  • ·HTTPS for all external communication
  • ·Hash passwords with bcrypt / scrypt / argon2
  • ·Set security headers (CSP, HSTS, X-Frame-Options)
  • ·httpOnly + secure + sameSite cookies for sessions
  • ·Run npm audit before every release
?
Ask first
Requires human approval
  • ·New auth flows or auth logic changes
  • ·Storing new categories of sensitive data (PII, payment)
  • ·New external service integrations
  • ·Changing CORS configuration
  • ·Adding file upload handlers
  • ·Modifying rate limiting or throttling
  • ·Granting elevated permissions or roles
Never do
Hard rules — no overrides
  • ·Commit secrets to version control
  • ·Log sensitive data (passwords, tokens, full PANs)
  • ·Trust client-side validation as a security boundary
  • ·Disable security headers for convenience
  • ·Use eval() or innerHTML with user-provided data
  • ·Store sessions in client-accessible storage
  • ·Expose stack traces or internal errors to users

Related