⚠️ Why This Matters
In early 2026, multiple security incidents were reported in the OpenClaw ecosystem:
- One-click remote code execution flaws (CVE-2026-25253)
- Plaintext credential storage in default configs
- Malicious skills on ClawHub marketplace
- API key leakage via agent logs and error messages
These are not theoretical risks. Hardening your gateway is not optional.
1. Secrets Management
Never store keys in shell history or service files
# Create secrets file
cat > ~/.config/openclaw/secrets.env << 'EOF'
OPENAI_API_KEY=sk-your-key-here
ANTHROPIC_API_KEY=sk-ant-your-key-here
EOF
# Lock down permissions (owner read-only)
chmod 600 ~/.config/openclaw/secrets.env
# Reference in systemd (NOT inline)
# EnvironmentFile=%h/.config/openclaw/secrets.env
Checklist
- ☐ All API keys in a single
secrets.envfile, never in CLI args - ☐ File permissions set to
600(owner read/write only) - ☐
secrets.envadded to.gitignore - ☐ No keys in
~/.bash_history— useHISTCONTROL=ignorespace
2. File System Permissions
Restrict access to OpenClaw's data directories.
# Lock down OpenClaw data directory
chmod 700 ~/.openclaw
chmod 700 ~/.openclaw/extensions
chmod 600 ~/.openclaw/openclaw.json
# Lock down session data (contains conversation history)
find ~/.openclaw/sessions -type f -exec chmod 600 {} \;
find ~/.openclaw/sessions -type d -exec chmod 700 {} \;
3. Skill & Plugin Vetting
Community skills can execute arbitrary code. Treat every skill install like running an untrusted script.
Before installing any skill:
- ☐ Read the source code — especially
SKILL.mdand anyscripts/directory - ☐ Check if it runs shell commands (
exec,spawn,child_process) - ☐ Check if it makes network requests to external endpoints
- ☐ Check if it accesses
process.env(could leak your API keys) - ☐ Verify the author's reputation on GitHub / Discord
- ☐ Prefer skills with recent commits and multiple contributors
Red flags:
- 🚩 Obfuscated or minified code in a skill
- 🚩 Skills that request broad file system access
- 🚩 Skills that disable security features or override configs
- 🚩 Newly created repos with no history or community engagement
4. Network Isolation
Don't expose the gateway port directly to the internet.
# Allow SSH only
ufw allow ssh
# Allow HTTP/HTTPS (for Nginx reverse proxy or Cloudflare)
ufw allow 80/tcp
ufw allow 443/tcp
# Do NOT open the gateway port (18789) to the internet
# ufw allow 18789/tcp ← NEVER DO THIS
# Enable firewall
ufw enable
ufw status
Recommended architecture:
- Option A: Cloudflare Tunnel (see Deploy recipe) — no open ports at all
- Option B: Nginx reverse proxy on localhost with HTTPS + rate limiting
- Never: Expose port 18789 directly to 0.0.0.0
5. Logging & Monitoring
Know what your agent is doing. Monitor for anomalies.
# Watch live logs
journalctl --user -u openclaw-gateway -f
# Search for errors
journalctl --user -u openclaw-gateway --since "1 hour ago" | grep -i error
# Check for shell command execution
journalctl --user -u openclaw-gateway --since today | grep -i "exec\|spawn\|shell"
# Check for failed authentication
journalctl --user -u openclaw-gateway --since today | grep -i "401\|403\|unauthorized"
What to watch for:
- Unexpected
execorspawncalls (agent running commands you didn't expect) - External HTTP requests to unknown domains
- Unusual API key usage patterns (high token burn)
- Authentication failures from unknown IPs
6. Stay Updated
- Subscribe to the OpenClaw releases RSS for security patches
- Check the Changelog on this site for breaking changes
- Join the OpenClaw Discord
#securitychannel - Run
npm auditperiodically in your OpenClaw install directory
# 1. Check current version
openclaw --version
# 2. Back up config
cp -r ~/.openclaw ~/.openclaw.bak.$(date +%Y%m%d)
# 3. Update
npm update -g openclaw
# 4. Restart
systemctl --user restart openclaw-gateway
# 5. Verify
systemctl --user status openclaw-gateway
curl -s http://127.0.0.1:18789/status
TL;DR Checklist
- ☐ API keys in
secrets.envwithchmod 600 - ☐
~/.openclawlocked to700 - ☐ Gateway port NOT exposed to internet
- ☐ Cloudflare Tunnel or Nginx reverse proxy for public access
- ☐ Every skill/plugin source-reviewed before install
- ☐ Firewall enabled (UFW or iptables)
- ☐ Logs monitored for anomalies
- ☐ Regular updates with backup-first strategy
Related
- Deploy on a VPS — the base deployment this playbook builds on
- Backup & Rollback — what to back up and how to restore
- Plugin API Changes — surviving breaking changes safely
- Changelog — track breaking changes and security patches