This document outlines the security measures implemented in the ThewworksICT e-commerce application and provides guidelines for maintaining a secure deployment.
- Supabase Authentication: Using JWT tokens for secure admin access
- Role-based access control: Admin-only endpoints require trusted
app_metadata.role=adminor an approved server-side email allowlist - Token validation: All API requests validated server-side
- Metadata hardening: User-editable
user_metadatais never trusted for authorization decisions
- AES-256-GCM Encryption: Customer PII (name, email, phone, address) encrypted at rest
- Secure Key Derivation: HKDF with salt for deriving encryption keys from secrets
- Timing-safe comparison: Constant-time comparison to prevent timing attacks
- Helmet.js: Comprehensive security headers
- Rate Limiting: Configurable rate limits per endpoint
- CSRF Protection: Token-based CSRF validation for state-changing operations
- Signed double-submit tokens: Browser mutations fetch
/api/security/csrf-tokenand echo the signed token inX-XSRF-TOKEN; Paystack webhooks are exempt from CSRF and protected by Paystack signatures - Input Validation: Zod schema validation on all inputs
- Request Size Limits: Configurable max body size (default: 5MB)
- Paystack Webhook Verification: Signature validation for payment webhooks
- Receipt Token Validation: Secure order lookup using hashed tokens
- Currency Validation: Prevent payment amount manipulation
- CORS: Whitelist-based origin validation
- HSTS: HTTP Strict Transport Security (1 year max-age in production)
- Content Security Policy: Prevent XSS and injection attacks
- Cache Control: Prevent sensitive data caching
| Variable | Description | Generate |
|---|---|---|
PAYSTACK_SECRET_KEY |
Paystack API key | Dashboard |
ORDER_STORE_ENCRYPTION_KEY |
Database encryption | openssl rand -base64 32 |
ORDER_TOKEN_SECRET |
Token signing | openssl rand -base64 32 |
CSRF_SECRET |
CSRF protection | openssl rand -hex 32 |
SUPABASE_SERVICE_ROLE_KEY |
Supabase admin | Dashboard |
| Variable | Description |
|---|---|
REDIS_URL |
Redis for rate limiting |
TURNSTILE_SITE_KEY |
Cloudflare Turnstile |
SECURITY_ALERT_WEBHOOK_URL |
Security alert Discord/Slack webhook |
CORS_ALLOWED_ORIGINS |
Additional comma-separated browser origins beyond PUBLIC_SITE_URL |
- All secrets replaced with production values in
.env -
NODE_ENV=productionset -
PUBLIC_SITE_URLset to production domain -
CORS_ALLOWED_ORIGINSlimited to trusted production origins only - Database SSL enabled (
DATABASE_SSL_MODE=require) - CSRF_SECRET minimum 32 characters
-
PAYSTACK_SECRET_KEYis a livesk_live_...key in production - Paystack webhook URL configured as
/api/payments/paystack/webhook; Paystack signs webhook requests with the live secret key inx-paystack-signature -
npm run security:env:check:productionpasses against the production environment - Redis configured for rate limiting (production)
- SSL/TLS certificate configured on load balancer
- WAF enabled (Cloudflare, AWS WAF, etc.)
- DDoS protection enabled
- Database in private subnet
- API only accessible via load balancer
- Backups configured
- Logging and monitoring active
- Security alerting configured
- Error logging active
- Performance monitoring
- Uptime monitoring
The application sets the following security headers:
| Header | Value | Purpose |
|---|---|---|
Strict-Transport-Security |
max-age=31536000; includeSubDomains; preload | HSTS |
Content-Security-Policy |
Restrictive CSP | XSS Prevention |
X-Content-Type-Options |
nosniff | MIME sniffing |
X-Frame-Options |
DENY | Clickjacking |
X-XSS-Protection |
1; mode=block | Legacy XSS |
Referrer-Policy |
no-referrer | Privacy |
Permissions-Policy |
camera=(), microphone=(), geolocation=() | Features |
Expect-CT |
max-age=31536000, enforce | Certificate Transparency |
- Mitigation: Parameterized queries via pg library
- Status: ✅ Protected
- Mitigation: Content Security Policy, input sanitization
- Status: ✅ Protected
- Mitigation: CSRF token validation
- Status: ✅ Protected
- Mitigation: X-Frame-Options: DENY
- Status: ✅ Protected
- Mitigation: HSTS, TLS 1.2+
- Status: ✅ Protected
- Mitigation: Rate limiting, WAF
- Status: ✅ Protected (with Redis/WAF)
- Mitigation: Paystack signature verification, receipt tokens
- Status: ✅ Protected
- Mitigation: AES-256-GCM encryption for PII
- Status: ✅ Protected
If you discover a security vulnerability, please report it to: stankingshomevalue@gmail.com
We appreciate responsible disclosure and will work to address issues promptly.
Regular security audits are recommended:
npm run security:auditUpdate dependencies regularly:
npm update
npm run security:audit:fixThis security documentation is part of the ThewworksICT e-commerce application.