Security Guide - Wedding RSVP App
Overview
This document outlines the security measures implemented in the Wedding RSVP application.
Security Features Implemented
- Zod Schema Validation: All API endpoints use Zod schemas for type validation
- Input Sanitization: String inputs are sanitized to remove potentially dangerous characters
- Email Validation: RFC-compliant email validation with additional security checks
- Length Limits: All inputs have appropriate length restrictions
2. Rate Limiting
- Login Attempts: 5 attempts per 15 minutes per IP address
- RSVP Submissions: 10 submissions per hour per IP address
- In-Memory Storage: Currently using Map-based storage (upgrade to Redis for production)
All API responses include comprehensive security headers:
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
Content-Security-Policy
: Restrictive CSP policy
4. Authentication Security
- Environment Variables: No hardcoded passwords in production
- Token Expiration: 24-hour token expiration
- IP Logging: Security events are logged with IP addresses
- Brute Force Protection: Delays and rate limiting prevent attacks
5. Data Validation
- Duplicate Prevention: Email addresses cannot be used multiple times for RSVPs
- Type Safety: TypeScript and Zod ensure data integrity
- Sanitized Storage: All stored data is sanitized before persistence
Security Recommendations for Production
Environment Configuration
Create a .env.local
file with secure values:
ADMIN_PASSWORD=your_very_secure_password_here
JWT_SECRET=your_32_character_minimum_jwt_secret
NODE_ENV=production
Network Security
- Deploy behind HTTPS (automatic with Vercel)
- Consider using a CDN with DDoS protection
- Enable CORS restrictions for API endpoints
Monitoring
- Set up logging for security events
- Monitor rate limiting triggers
- Track failed authentication attempts
Known Security Considerations
Current Limitations
- Token Storage: Currently uses localStorage (client-side vulnerability)
- Rate Limiting: In-memory storage (resets on server restart)
- File Storage: Using JSON files instead of encrypted database
Future Improvements
- Implement httpOnly cookies for token storage
- Upgrade to Redis for persistent rate limiting
- Add proper JWT with refresh tokens
- Implement database encryption
- Add request signing for API calls
Security Checklist
Incident Response
If a security issue is discovered:
- Check logs for the extent of the issue
- Review rate limiting logs
- Check for unusual patterns in RSVP submissions
- Update credentials if compromised
- Review and update security measures
For security concerns, please review the logs and consider the recommendations in this guide.