| name | security-guidelines |
| description | Application security guidelines covering input validation, XSS prevention, SQL injection, authentication, and secrets management. Auto-loaded when implementing authentication, handling user input, or managing secrets. |
| category | guideline |
| user-invocable | false |
Security Guidelines
Core Principles
- Defense in depth — Multiple layers of security
- Least privilege — Minimum permissions required
- Fail secure — Default to denying access
- Never trust input — Validate everything from external sources
- Keep secrets secret — Never expose sensitive data
Input Validation
Always validate external input (URL params, request body, query strings, headers, file uploads, WebSocket messages).
import { z } from 'zod';
const UserInputSchema = z.object({
email: z.string().email().max(),
: z.().().(),
: z.().().().().(),
});
() {
.(input);
}
(): {
(!.(id)) {
();
}
id;
}