You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validate all request bodies, query params, and path params with Zod schemas.
Reject requests with unexpected fields (z.object().strict()).
Sanitize all user input before database insertion.
Limit request body size (express.json({ limit: '10mb' })).
Rate Limiting
Apply rate limiting per IP and per user:
Auth endpoints: 5 requests/minute
API endpoints: 100 requests/minute
File uploads: 10 requests/minute
3D generation: 5 requests/hour (per user tier)
CORS
Restrict Access-Control-Allow-Origin to the frontend domain only.
Never use * for CORS origin in production.
Enable credentials: true for cookie-based auth.
Headers
Use Helmet.js for security headers:
Content-Security-Policy — restrict script sources
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Strict-Transport-Security — HSTS enabled
Referrer-Policy: strict-origin-when-cross-origin
3. Data Protection
Secrets Management
Never commit secrets to version control.
All API keys and credentials go in .env.local (frontend) or .env (backend).
Add .env* to .gitignore (except .env.example).
Rotate API keys periodically — World Labs, UploadThing, Uploadcare, Supabase.
Use environment-specific keys (dev, staging, production).
Database Security
All tables must have RLS enabled — see docs/DATABASE.md.
Never expose database connection strings to the frontend.
Use parameterized queries — never concatenate user input into SQL.
Encrypt sensitive fields at rest (phone numbers, financial data).
Regular backups via Supabase's built-in backup system.
File Upload Security
Validate file types server-side (not just by extension — check MIME type / magic bytes).
Enforce file size limits per upload route.
Scan uploaded files for malware before processing (for 3D generation pipeline).
Store uploaded files in private buckets — serve via signed URLs with expiry.
Never allow users to control the file path or filename on the server.
4. Frontend Security
No sensitive data in client-side code — API keys that appear in NEXT_PUBLIC_* must be safe for public exposure (e.g., Supabase anon key, Mapbox public token).
XSS prevention: React handles escaping by default. Never use dangerouslySetInnerHTML unless absolutely necessary with sanitized content.
CSRF protection: Use SameSite=Strict or SameSite=Lax cookies.