This document outlines the security measures implemented in BookAThing.
- Server: Updated
firebase-adminfrom v11.11.1 to v13.6.0 to fix criticalprotobufjsvulnerability - Client: Added npm overrides for vulnerable dependencies (
nth-check,postcss,webpack-dev-server,svgo) - All npm audit vulnerabilities have been resolved
- Before: Allowed all origins (
*) - security risk - After: Restricted to whitelisted origins in production
- Configure allowed origins via
ALLOWED_ORIGINSenvironment variable - Development mode allows all origins for convenience
- API Routes: 100 requests per 15 minutes per IP
- Booking Creation: 10 bookings per hour per IP (prevents abuse)
- Helps prevent DoS attacks and booking spam
- All user inputs are validated and sanitized using the
validatorlibrary - Name: 2-100 characters, HTML-escaped
- Email: Validated format, normalized
- Phone: 7-20 characters for international formats
- Notes: Max 500 characters, HTML-escaped
- Date/Time: Validated using moment.js
- Prevents XSS and injection attacks
Protected endpoints now require API key authentication via X-API-Key header:
GET /api/bookings- View all bookingsDELETE /api/bookings/:id- Cancel bookingsPUT /api/bookings/:id/status- Update booking statusPUT /api/resources/:id/status- Update resource status
- Implemented
helmetmiddleware for security headers - Protects against common web vulnerabilities
- JSON payload limited to 10MB to prevent memory exhaustion attacks
- Generate a secure random API key:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"- Add to your
.envfile:
ADMIN_API_KEY=your-generated-key-here- Use the API key when making requests to protected endpoints:
curl -H "X-API-Key: your-generated-key-here" http://localhost:5000/api/bookingsSet allowed origins in production:
ALLOWED_ORIGINS=https://yourdomain.com,https://app.yourdomain.comCopy .env.example to .env and configure:
cd server
cp .env.example .env
# Edit .env with your values- Never commit
.envfiles - They contain sensitive credentials - Use strong API keys - At least 32 random bytes
- Enable HTTPS in production - Use SSL/TLS certificates
- Keep dependencies updated - Run
npm auditregularly - Monitor rate limits - Adjust based on your traffic patterns
- Backup your data - If using Firebase, enable automated backups
- Review logs - Monitor for suspicious activity
If you discover a security vulnerability, please email the maintainer directly rather than opening a public issue.
- Set
NODE_ENV=production - Configure
ADMIN_API_KEYwith a strong random value - Set
ALLOWED_ORIGINSto your production domain(s) - Enable HTTPS/SSL
- Set up Firebase (if using persistent storage)
- Configure firewall rules
- Enable logging and monitoring
- Set up automated backups
- Review and adjust rate limits if needed
- Remove any test/development accounts