Security patterns and hardening practices for this monorepo. Use when implementing authentication, configuring CORS, validating input, handling secrets, securing API endpoints, or reviewing code for vulnerabilities. Triggers on tasks involving security, auth guards, env validation, CORS, CSP, rate limiting, or OWASP compliance.
설치
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
Security patterns and hardening practices for this monorepo. Use when implementing authentication, configuring CORS, validating input, handling secrets, securing API endpoints, or reviewing code for vulnerabilities. Triggers on tasks involving security, auth guards, env validation, CORS, CSP, rate limiting, or OWASP compliance.
Define validation in contracts, not in controllers or services
Always set .min() and .max() for strings
Use .int().positive() for IDs
Use .email() for email fields
Use .url() for URL fields
Never trust raw req.body — always go through contract validation
Validation Error Response Format
When validation fails, the HttpExceptionFilter returns:
{"success":false,"error":{"code":"BadRequestException","message":["title: String must contain at least 1 character"],"details":{}},"timestamp":"2025-07-12T00:00:00.000Z"}
Error Masking
The HttpExceptionFilter ensures internal errors never leak to clients:
// Only catches HttpException (not raw Error)// Strips internal details// Returns consistent error format// Logs ZodSerializationException details to console (not response)
Rules:
Never throw raw Error — always wrap in HttpException or subclass
Never include stack traces in responses
Log full error details server-side, return safe messages client-side
Use appropriate HTTP status codes (400, 401, 403, 404, 500)
Network Security (AWS)
Security Group Rules
ALB SG:
Inbound: 80 (HTTP), 443 (HTTPS) from 0.0.0.0/0
Outbound: All
Web ECS SG:
Inbound: 3001 from ALB SG only
Outbound: All
Backend ECS SG:
Inbound: 3000 from ALB SG only
Outbound: All
Rules:
ECS tasks are in private subnets (no public IP)
Only ALB can reach ECS services (SG-to-SG reference)
Outbound allowed for external API calls and database connections