Input Sanitization Library
Build a comprehensive input sanitization layer for user-submitted data
Build an input sanitization layer for: **Input types:** [TYPES — e.g., "form fields, URL params, file uploads, rich text editor"] **Framework:** [FRAMEWORK — e.g., "Next.js with Zod validation"] Generate: 1. **Sanitization functions** — for each data type: - String: trim, escape HTML, strip control characters - Email: normalize, validate RFC 5322 - URL: validate protocol, prevent SSRF - HTML (rich text): allowlist tags/attributes, strip dangerous content - File upload: validate MIME type, extension, magic bytes 2. **SQL injection prevention** — parameterized query enforcement 3. **XSS prevention** — context-aware output encoding (HTML, JS, URL, CSS) 4. **Path traversal prevention** — normalize and validate file paths 5. **Zod schemas** — validation schemas with built-in sanitization transforms 6. **Middleware** — automatic sanitization for all incoming request data 7. **Tests** — test with OWASP attack payloads Include the sanitization library, middleware, and comprehensive test suite.
How to Use This Prompt
- 1Copy the prompt template above
- 2Paste into Claude, ChatGPT, or Cursor
- 3Replace [bracketed placeholders] with your specific project details
- 4Iterate on the AI output to refine and customize the results
More Security Prompts
Related security templates from the vault
SQL Injection Prevention Guide
Use this prompt to sql injection prevention guide with AI assistance
Supply Chain Attack Prevention Checklist
PROAudit and harden your software supply chain against dependency attacks, compromised packages, and build pipeline tampering
OWASP Top 10 Audit Checklist
Use this prompt to owasp top 10 audit checklist with AI assistance
JWT Authentication Implementation
Implement secure JWT-based authentication with refresh tokens
You Might Also Like
Prompts from other categories that share similar tags
Authentication System with JWT
Implement a complete authentication system with signup, login, and session management
Environment Variable Setup Guide
Set up environment variables properly across development, staging, and production
Multi-Tenant Architecture Planner
Design multi-tenant isolation strategies for SaaS applications
Accessible Form with Validation
Build a form with proper accessibility, validation, and error handling
Keep Exploring the Vault