Input Sanitization Patterns
Implement proper input sanitization for common attack vectors
Show me how to properly sanitize user input in my [FRAMEWORK] application. Cover these attack vectors with before/after code examples: 1. **SQL Injection** - Vulnerable pattern - Parameterized query fix - ORM-safe patterns 2. **XSS (Cross-Site Scripting)** - Stored XSS scenario - Reflected XSS scenario - Content Security Policy header - React's built-in protections and their limits (dangerouslySetInnerHTML) 3. **Command Injection** - Vulnerable pattern with child_process - Safe alternative 4. **Path Traversal** - Vulnerable file access pattern - Safe path resolution 5. **SSRF (Server-Side Request Forgery)** - Vulnerable URL fetch pattern - URL validation and allowlisting For each: - Show the vulnerable code (what NOT to do) - Show the secure code (what TO do) - Explain why the fix works - Provide a test case that would catch the vulnerability Framework-specific: use [FRAMEWORK] idioms and built-in protections where available.
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
Content Security Policy Builder
PROGenerate a strict Content Security Policy for your web application
You Might Also Like
Prompts from other categories that share similar tags
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
Row-Level Security Policy Generator
Implement PostgreSQL Row-Level Security for multi-user data isolation
Authentication System with JWT
Implement a complete authentication system with signup, login, and session management
Keep Exploring the Vault