OpenClaw Security & Hardening
Secure your OpenClaw deployment. SSL/TLS, authentication, skill vetting, data encryption, rate limiting, network hardening, and incident response.
Prerequisites
OpenClaw deployed on VPS or server ยท Linux administration basics ยท Network security understanding
OpenClaw Security & Hardening
Running an AI assistant with access to your data, systems, and integrations requires serious security. OpenClaw touching your emails, smart home, financial data, and customer information means a breach could be catastrophic. This guide covers hardening OpenClaw for production use and securing your entire stack.
Understanding Your Threat Model
Before hardening, understand what you're protecting against:
Threat Level 1: Personal Use (Low Risk)
- Local network only
- Single user
- Limited sensitive data
- Threats: Accidental exposure, skill bugs
- Protection: Strong passwords, regular updates
Threat Level 2: Small Business (Medium Risk)
- Internet-facing
- Multiple users
- Contains customer/business data
- Threats: Hackers, disgruntled employees, skill vulnerabilities
- Protection: SSL, authentication, audit logs, rate limiting
Threat Level 3: Enterprise (High Risk)
- Public-facing
- Hundreds of users
- Sensitive data (health, financial, PII)
- Threats: Sophisticated attackers, compliance violations, data breaches
- Protection: Full hardening, penetration testing, insurance
Most small businesses need Threat Level 2. Enterprises need Level 3.
Phase 1: Network Security
Enable HTTPS/SSL
Install Let's Encrypt certificate (free SSL):# Install Certbot
apt-get install certbot python3-certbot-nginx -y
Generate certificate
certbot certonly --standalone -d yourdomain.com -d www.yourdomain.com
Verify installation
ls /etc/letsencrypt/live/yourdomain.com/
Configure OpenClaw to use SSL:
Edit your docker-compose.yml:
openclaw-api:
environment:
- SECURE=true
- CERT_PATH=/etc/letsencrypt/live/yourdomain.com/fullchain.pem
- KEY_PATH=/etc/letsencrypt/live/yourdomain.com/privkey.pem
volumes:
- /etc/letsencrypt:/etc/letsencrypt:ro
ports:
- "8000:8000" # Keep only HTTPS
Auto-renew certificates:
# Create renewal cron job
echo "0 12 * certbot renew --quiet" | crontab -
Network Isolation
Restrict who can access your OpenClaw instance:
Allow only trusted IPs:# In your firewall (UFW on Linux)
ufw default deny incoming
ufw default allow outgoing
ufw allow from 203.0.113.5 to any port 22 # Only your IP for SSH
ufw allow from 203.0.113.5 to any port 8000 # Only your IP for OpenClaw
ufw allow to any port 443 # HTTPS for everyone
ufw allow to any port 80 # HTTP (redirect only)
ufw enable
Use a VPN for remote access:
Instead of exposing OpenClaw to the internet, use a VPN:
# Install WireGuard (lightweight VPN)
apt-get install wireguard -y
Configure WireGuard
... setup steps
Access OpenClaw only through VPN
DDoS Protection
Prevent denial-of-service attacks:
Enable Cloudflare (free tier):- Point your domain to Cloudflare nameservers
- Enable DDoS protection (automatic on free tier)
- Set rate limiting: Cloudflare dashboard > Security > Rate Limiting
- Configure: 50 requests per IP per minute
settings:
rate_limiting:
enabled: true
requests_per_minute: 100
requests_per_hour: 5000
burst_limit: 20
Phase 2: Authentication & Authorization
Change Default Credentials
Immediately change admin password:# On local OpenClaw instance
docker-compose exec openclaw-api python manage.py changepassword admin
Enter new password (strong: 20+ chars, mix of types)
Change database password:
Edit .env file:
# Before (default)
POSTGRES_PASSWORD=openclaw
After (strong password)
POSTGRES_PASSWORD=oP3nCl4w!@#$%^&*()_+={}[]|:;<>?,./~`
Implement Multi-Factor Authentication (MFA)
Require MFA for admin accounts:
# In OpenClaw Settings > Security > MFA
Enable MFA for all administrators
Users scan QR code with authenticator app (Google Authenticator, Authy)
Backup codes generated (save in secure location)
API Key Management
If using API keys for programmatic access:
# Generate new API key
Settings > Developers > API Keys > Generate New
Best practices:
1. Rotate keys quarterly
2. Use separate keys for different purposes
3. Revoke old keys immediately
4. Store securely (never in code, use environment variables)
Example .env usage
OPENCLAW_API_KEY=sk-proj-abc123...
User Roles & Permissions
Implement least privilege access:
# Create role groups in OpenClaw
Settings > Users & Roles
Roles:
- Admin: Full access (restrict to 1-2 people)
- Manager: Can view reports, manage teams (5-10 people)
- User: Can only use automations they own (everyone else)
- Viewer: Read-only access (external auditors)
Phase 3: Data Protection
Database Encryption
Enable encryption at rest:# PostgreSQL encryption
Edit /etc/postgresql/postgresql.conf
encryption = on
ssl = on
ssl_cert_file = '/etc/ssl/certs/openclaw.crt'
ssl_key_file = '/etc/ssl/private/openclaw.key'
Restart PostgreSQL
systemctl restart postgresql
Encrypted backups:
#!/bin/bash
backup_encrypted.sh
BACKUP_DIR="/backups"
DATE=$(date +%Y%m%d_%H%M%S)
Create encrypted backup
docker-compose exec postgres pg_dump openclaw | \
openssl enc -aes-256-cbc -pass file:/path/to/encryption.key \
> $BACKUP_DIR/openclaw_$DATE.sql.enc
Verify backup
openssl enc -aes-256-cbc -d -in $BACKUP_DIR/openclaw_$DATE.sql.enc -pass file:/path/to/encryption.key | head
Clean old backups
find $BACKUP_DIR -name "*.sql.enc" -mtime +90 -delete
Upload to secure cloud storage
aws s3 cp $BACKUP_DIR/openclaw_$DATE.sql.enc s3://your-encrypted-backups/ --sse AES256
Encryption in Transit
All data between services uses encryption:
# docker-compose.yml
services:
openclaw-api:
environment:
- DATABASE_REQUIRE_SSL=true
- REDIS_REQUIRE_SSL=true
Secrets Management
Never commit secrets to Git:
# Create .env.example (for documentation)
Commit to Git: NO actual values
OPENCLAW_API_KEY=your_api_key_here
DATABASE_PASSWORD=database_password_here
SECRET_KEY=your_secret_key_here
Create actual .env (never commit)
OPENCLAW_API_KEY=sk-proj-abc123xyz789...
DATABASE_PASSWORD=oP3nCl4w!@#$%^&*()
SECRET_KEY=$(openssl rand -base64 32)
Add to .gitignore
echo ".env" >> .gitignore
echo "config.json" >> .gitignore
echo "secrets/" >> .gitignore
Phase 4: Skill Security
Vetting Skills Before Installation
Security checklist before installing ANY skill:- Author Reputation
- Look for reviews (issues/complaints)
- Verify author responds to issues
- Permissions Requested
- For example, "photo management" skill shouldn't request email access
- If unclear, ask author in GitHub issues
- Code Review (for popular skills)
- Search code for suspicious patterns:
- "requests.post" to unknown domains
- Credentials hard-coded
- Data exfiltration logic
- Unusual base64 strings
- Update Frequency
- Last update >1 year ago is concerning
- Check if security issues were addressed
- User Reviews
- Look for complaints about privacy/security
- High number of negative reviews = red flag
Rejected if:- Author has reputation issues
- Requests suspicious permissions
- Contains obfuscated/hidden code
- No updates for >2 years
- Multiple complaints about security
Monitoring Skill Behavior
After installation, monitor what skills do:
# View skill logs
docker-compose logs -f openclaw-api | grep "skill_name"
Check what APIs a skill accesses
docker-compose exec openclaw-api \
grep -r "requests.post\|requests.get" skills/skill_name/
Monitor skill resource usage
docker stats
Alert on unusual behavior
Settings > Monitoring > Alert on:
- Skill using >50% CPU for >10 minutes
- Skill consuming >500MB RAM
- Skill making 100+ external API calls/minute
Disabling Dangerous Skills
If a skill is compromised or acting suspiciously:
# Immediately disable the skill
Settings > Skills > Installed > [Skill Name] > Disable
Check logs for damage
docker-compose logs openclaw-api | tail -1000 > /tmp/logs.txt
If necessary, remove the skill
Settings > Skills > Installed > [Skill Name] > Delete
Rotate all credentials the skill had access to
Example: If email skill was compromised, change email password
Phase 5: Monitoring & Logging
Enable Comprehensive Logging
# docker-compose.yml
openclaw-api:
environment:
- LOG_LEVEL=INFO # Or DEBUG for more detail
- LOG_FORMAT=json # Structured logging
- ENABLE_AUDIT_LOG=true
- ENABLE_API_LOG=true
Review Logs Regularly
# Daily log review
docker-compose logs --since 24h openclaw-api | \
grep -i "error\|warning\|unauthorized\|failed"
Check for unauthorized access attempts
docker-compose logs openclaw-api | grep "unauthorized\|403\|401"
Monitor API usage
docker-compose logs openclaw-api | grep "POST\|DELETE" | wc -l
Set Up Alerts
# Create alert for suspicious activity
Settings > Monitoring > Alerts
Alerts:
- 3+ failed login attempts in 5 minutes โ Email alert
- Any DELETE request โ Email alert + require approval
- Skill accessing data > 10x normal rate โ Disable skill + email
- Database backup failure โ Critical alert
Use Security Information & Event Management (SIEM)
For enterprises, use ELK Stack (Elasticsearch, Logstash, Kibana):
# Simple ELK setup with Docker
docker run -d -p 9200:9200 docker.elastic.co/elasticsearch/elasticsearch:7.17.0
docker run -d -p 5601:5601 docker.elastic.co/kibana/kibana:7.17.0
Configure OpenClaw to send logs to Elasticsearch
Settings > Logging > Elasticsearch
Host: localhost
Port: 9200
Phase 6: Vulnerability Management
Keep Everything Updated
# Weekly: Check for updates
docker-compose pull
git pull origin main
Monthly: Update OS packages
apt-get update && apt-get upgrade -y
Quarterly: Full security audit
Review all: skills, configurations, access logs
Subscribe to security advisories
GitHub > openclaw-ai/openclaw > Watch > Custom > Security alerts
Patch Management Process
When a CVE (security vulnerability) is announced:
- Immediate (same day):
- Temporarily disable vulnerable component if necessary
- Monitor for exploitation attempts
- Short-term (within 48 hours):
- Test thoroughly in non-production first
- Deploy to production
- Post-patch:
- Review logs for prior exploitation
- Update incident response plan
CVE Monitoring
# Subscribe to CVE feeds
Security advisories: https://nvd.nist.gov
OpenClaw advisories: https://github.com/openclaw-ai/openclaw/security/advisories
Set up automated scanning
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
aquasec/trivy image openclaw:latest
Phase 7: Incident Response Plan
Create a Response Plan
Before an incident happens, have a plan:# OpenClaw Incident Response Plan
Response Levels
Level 1 (Low): Bug in skill
- Disable skill
- Review logs for impact
- Patch and test
- Re-enable
Level 2 (Medium): Unauthorized access to automation
- Disable affected automation
- Change related passwords
- Review audit logs
- Implement access restrictions
- Notify affected users
Level 3 (High): Data breach
- Immediately take OpenClaw offline
- Preserve all logs
- Contact your incident response team
- Notify affected parties (if required by law)
- Conduct forensic investigation
- Deploy patches
- Communicate findings publicly
Response Team
- Incident Commander: You or your IT lead
- Technical Lead: Developer familiar with OpenClaw
- Communication Lead: Person authorized to communicate incidents
- Legal/Compliance: If company has legal team
Contact Information
- ISP: [contact info]
- Security firm (for forensics): [contact info]
- Customers (for notification): [contact database]
Incident Playbook
When a breach is discovered:
# Step 1: Containment (first 30 minutes)
Isolate affected systems
iptables -A INPUT -p tcp --dport 8000 -j DROP
Preserve evidence
docker-compose logs > /tmp/incident_logs.txt
cp -r ~/.openclaw-config /tmp/incident_backup/
Step 2: Investigation (next 2 hours)
Determine scope of breach
grep "unauthorized\|admin.*login" /tmp/incident_logs.txt
grep "skill.*access" /tmp/incident_logs.txt
Step 3: Remediation
Change all passwords
Rotate API keys
Patch vulnerabilities
Re-enable systems gradually
Step 4: Recovery
Restore from backup (if not infected)
Re-enable with enhanced monitoring
Security Checklist
Print this checklist and verify monthly:
[ ] HTTPS/SSL enabled with valid certificate
[ ] Admin password changed from default
[ ] MFA enabled for all admin accounts
[ ] Database encrypted at rest
[ ] Backups encrypted and stored off-site
[ ] Rate limiting enabled
[ ] Firewall configured (only necessary ports open)
[ ] All skills reviewed for security
[ ] Suspicious skills disabled
[ ] Logs reviewed in past 7 days
[ ] No unauthorized users in user list
[ ] API keys rotated in past 90 days
[ ] OpenClaw updated to latest version
[ ] Dependencies updated in past month
[ ] Incident response plan created and tested
[ ] Security monitoring alerts configured
Frequently Asked Questions
Q: Is self-hosting more or less secure than cloud?A: Different tradeoffs. Self-hosted: You control data but manage all updates. Cloud: Vendor handles updates but data on their servers. Choose based on compliance needs.
Q: How often should I backup?A: At minimum daily. For high-risk data: every 4 hours. Test restores monthly.
Q: What if OpenClaw is breached?A: Immediately take offline, preserve logs, investigate scope, patch, restore from clean backup, notify users if their data was accessed.
Q: How do I know if a skill is malicious?A: Check: author reputation, code review, permissions requested, user reviews. When in doubt, don't install.
Q: Should I use OpenClaw for HIPAA/PCI compliance?A: Possible with proper configuration (encryption, audit logs), but requires legal review and may need vendor support/audit.
Next Steps
Your OpenClaw instance is hardened. What's next?
- Multi-Agent Systems โ Scale with multiple agents safely
- Business Operations โ Extend security to business automation
- Join OpenClaw security community to stay informed about vulnerabilities