Security-Focused Prompts
Security-Focused Prompts
Introduction
Core Security Principles
Prompt Templates
General Security-Focused Template
SITUATION: [Describe the system, existing architecture, and security context]
CHALLENGE: Create [describe component] that prioritizes security while ensuring functionality
AUDIENCE: Development team with security requirements for [specific compliance/security standard]
FORMAT:
- Implement proper input validation for all external data
- Use parameterized queries for all database operations
- Apply the principle of least privilege throughout
- Include comprehensive error handling that doesn't leak sensitive information
- Add security-focused comments explaining protection mechanisms
FOUNDATIONS:
- Follow OWASP Top 10 mitigation strategies
- Implement proper authentication and authorization checks
- Validate all inputs with appropriate sanitization
- Use secure cryptographic practices where needed
- Handle sensitive data according to [relevant compliance standards]
- Include security-focused logging without exposing sensitive informationAuthentication Component Template
Data Access Security Template
API Security Template
Frontend Security Template
Component-Specific Security Prompts
Secure File Upload Implementation
Payment Processing Security
OWASP Top 10 Mitigation Prompts
Injection Prevention
Broken Authentication Mitigation
Sensitive Data Exposure Prevention
XML External Entity Attack Prevention
Broken Access Control Mitigation
Best Practices for Security-Focused Prompts
Request Threat Modeling
Specify Security Testing Requirements
Request Security Documentation
Specify Compliance Requirements
Evaluating Security Results
Example: Before and After
Before: Insecure Authentication Implementation
After: Secure Authentication Implementation
Security Anti-Patterns to Avoid
Conclusion
Last updated