--- description: Security basics — secrets, auth, injection, and safe defaults alwaysApply: true --- # Security Basics - Never commit secrets, API keys, tokens, or passwords. Use environment variables. - Never log passwords, tokens, session IDs, or full credit card numbers. - Parameterize all database queries. Never concatenate user input into SQL. - Escape or sanitize user-generated content before rendering in HTML. - Validate and whitelist file uploads: type, size, and storage path. - Use HTTPS for all external API calls in production code paths. - Apply least-privilege: services and DB users get only the permissions they need. - Check authorization on every mutating endpoint — authentication alone is not enough. - Set secure cookie flags (`HttpOnly`, `Secure`, `SameSite`) for session cookies. - Do not disable TLS certificate verification in production code.