typescript-security
Installation
SKILL.md
TypeScript Security
Priority: P0 (CRITICAL)
Validate Input at Boundaries
- Use
Zod,Joi, orclass-validatorat API boundary. Alwaysparseand validateuser-controlled inputbefore using. UsesafeParsefor error handling without throwing. Return400 with structured errorson failure.
See references/REFERENCE.md for Zod validation schemas, secure cookie setup, and JWT auth patterns.
Prevent Injection and XSS
- Sanitization: Use
DOMPurifyfor HTML sanitization to prevent Cross-Site Scripting (XSS). - SQL Injection: Use Parameterized Queries (e.g.,
pool.query('... WHERE id = $1', [id])) or Type-safe ORMs (Prisma/TypeORM). UsePrisma.sqlfor raw queries. - Input Filtering: Sanitize
user-controlled inputbefore using it in file paths or OS commands (Command Injection).