This document outlines the security measures implemented in the CV Adapter application.
- Uses Firebase Auth for user authentication with email/password
- ID tokens are exchanged for secure session cookies server-side
- Session cookies are HTTP-only, secure, and use strict SameSite policy
- Sessions expire after 7 days (reduced from 14 days for better security)
- Server-side session validation in middleware
- Automatic session refresh when close to expiry (< 1 hour remaining)
- Session revocation on logout with refresh token invalidation
- Invalid sessions are automatically cleared
The following security headers are automatically applied:
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()
- Authentication endpoints: 5 requests per 15 minutes per IP
- General API endpoints: 10 requests per 15 minutes per IP
- Implemented in middleware with automatic blocking
- Login attempts: 5 failed attempts trigger 15-minute block
- Block status stored in localStorage
- Visual feedback for remaining block time
- Minimum 8 characters, maximum 128 characters
- Must contain:
- At least one uppercase letter
- At least one lowercase letter
- At least one digit
- At least one special character
- Forbidden common passwords (password, 12345678, etc.)
- Real-time strength indicator in signup form
- Server-side validation on all password inputs
- Client-side validation with visual feedback
- RFC 5321 compliant email format checking
- Maximum length validation (254 characters)
- Automatic lowercase conversion and trimming
- JSON parsing error handling
- Input type validation
- Length limits on all inputs
- XSS prevention through proper encoding
- Requires
X-Requested-With: XMLHttpRequestheader on auth requests - Validates request origin
- Session cookies with strict SameSite policy
All authentication events are logged to Firestore audit_logs collection:
- Login success/failure
- Signup success/failure
- Logout events
- Session refresh attempts
- Unauthorized access attempts
- Invalid session detection
- Account disabled access attempts
- Event type and timestamp
- User ID and email (when available)
- IP address and User-Agent
- Success/failure status
- Additional context data
user: Standard user accessvip: VIP user with unlimited featuresadmin: Administrative access
- Middleware validates sessions on protected routes
- Role verification for admin routes
- Automatic redirection for unauthorized access
- Sensitive fields excluded from API responses
- User activity tracking (last login, last activity)
- Account status monitoring
- Firestore security rules (configure separately)
- Indexed fields for efficient queries
- Audit trail for all authentication events
- Centralized authentication context management
- Role-based authorization helpers
- User activity tracking
- Input validation utilities
- Centralized security configuration
- Password policy definitions
- Rate limiting settings
- Security header configuration
Ensure these are set securely in production:
NODE_ENV=production
FIREBASE_PROJECT_ID=your-project-id
FIREBASE_CLIENT_EMAIL=your-service-account-email
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----..."
- Enable HTTPS/SSL certificates
- Configure proper CORS policies
- Set up monitoring and alerting for security events
- Regularly rotate service account keys
- Implement proper backup and disaster recovery
- Consider implementing additional MFA for admin accounts
Monitor the audit_logs collection for:
- Repeated failed login attempts from same IP
- Unusual login patterns or times
- Multiple account access from same IP
- Failed authorization attempts
- Multiple failed logins (> 10 per hour)
- Admin access outside business hours
- Disabled account access attempts
- Unusual geographic access patterns
- Never log sensitive data (passwords, tokens)
- Validate all inputs on both client and server
- Use parameterized queries for database operations
- Keep dependencies updated
- Follow principle of least privilege
- Use strong, unique passwords
- Don't share account credentials
- Log out from shared devices
- Report suspicious activity immediately
In case of security incidents:
- Check audit logs for affected accounts
- Revoke sessions for compromised accounts
- Monitor for unusual patterns
- Update security measures as needed
- Document lessons learned
Regular security testing should include:
- Penetration testing
- Vulnerability scanning
- Authentication bypass testing
- Session management testing
- Input validation testing
- Rate limiting verification
For security concerns or questions, please review the audit logs and implement additional monitoring as needed for your specific deployment.