This is the SECURE version of OpenClaw Command Center with the following security enhancements:
- β API Key Authentication - All endpoints require valid API key
- β Rate Limiting - Prevents abuse and DoS attacks
- β Helmet Security Headers - CSP, HSTS, XSS protection
- β CORS Protection - Configurable allowed origins
- β Input Validation - Whitelisting and sanitization
- β WebSocket Authentication - Session-based auth with timeout
- β Security Logging - All security events are logged
- β Secure Defaults - Binds to localhost by default
# Generate a secure API key
openssl rand -hex 32cp .env.example .env
nano .envSet your API keys:
API_KEYS=your-generated-api-key-here
npm installnpm startInclude your API key in requests:
# Via header (recommended)
curl -H "X-API-Key: your-api-key" http://localhost:3000/api/status
# Via Authorization header
curl -H "Authorization: Bearer your-api-key" http://localhost:3000/api/status- First, obtain a session token:
curl -X POST http://localhost:3000/api/auth/session \
-H "Content-Type: application/json" \
-d '{"apiKey": "your-api-key"}'- Authenticate WebSocket connection:
const ws = new WebSocket('ws://localhost:3000');
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'auth',
token: 'your-session-token'
}));
};| Endpoint Type | Requests/Minute |
|---|---|
| General API | 120 |
| Voice (STT) | 20 |
| Voice (TTS) | 30 |
| Auth | 10 |
| Health | 120 |
View recent security events:
curl -H "X-API-Key: your-api-key" \
http://localhost:3000/api/security/log-
Use a reverse proxy (nginx, Caddy, Traefik) with:
- SSL/TLS termination
- Additional rate limiting
- Request logging
-
Set environment variables:
NODE_ENV=production BIND_ADDRESS=127.0.0.1 TRUST_PROXY=true CORS_ORIGINS=https://yourdomain.com -
Use HTTPS - Either:
- Place cert.pem and key.pem in server/ directory, OR
- Use reverse proxy with SSL
server {
listen 443 ssl http2;
server_name yourdomain.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}- API keys configured and kept secret
- .env file is NOT in version control
- BIND_ADDRESS set to 127.0.0.1 (or use reverse proxy)
- CORS_ORIGINS configured for your domains only
- HTTPS enabled (direct or via reverse proxy)
- Rate limiting tested
- Security logging enabled
- Regular security updates applied
If you discover a security vulnerability, please report it privately.
- Added API key authentication
- Added rate limiting
- Added Helmet security headers
- Added CORS protection
- Added input validation
- Added WebSocket authentication
- Added security event logging
- Changed default bind address to localhost
- Added file type validation for uploads
- Added request ID tracking