I like OpenClaw because it can actually do things: read files, run commands, interact with APIs, and automate repeat work. That same power is exactly why security matters. If deployment boundaries are sloppy, mistakes turn into incidents fast.
This is the hardening flow I use when I want OpenClaw to be useful and safe. It is written for operators, not for demo videos.
Why this is a different security problem
A normal chatbot gives you text. OpenClaw can take actions. The risk profile changes immediately:
- It can touch multiple systems in one workflow (chat, email, files, APIs).
- It can make decisions from untrusted text input.
- It can execute faster than human review if you remove approval gates.
In practice, risk comes from three multipliers: permissions, exposure, and autonomy.
Threat model in plain English
These are the paths I care about first:
- Prompt-injection path: untrusted input influences tool use.
- Credential path: token/key leakage expands attacker reach.
- Control-plane path: exposed gateway lets attackers probe auth and automation surface.
- Privilege path: broad shell/file permissions turn one bad decision into host-level damage.
One realistic chain looks like this: external message → malicious instruction → tool invocation → data exfiltration or config tampering. You don't need a zero-day for that, just weak boundaries.
What OpenClaw can touch (and why that matters)
- Email/chat: high social-engineering value, easy impersonation if compromised.
- Browser automation: can interact with authenticated sessions and sensitive pages.
- File system: potential access to secrets, configs, and local artifacts.
- System commands: highest-impact capability when unrestricted.
- External APIs: can become cloud/payment/productivity control channels.
Every integration is a trust expansion. Treat each one like adding a new attack path, because that is exactly what it is.
The failure patterns I keep seeing
Most incidents are boring and preventable. Common setup failures:
- Gateway exposed publicly with weak controls.
- Agent running with elevated privileges.
- Tool permissions left broad after "temporary testing."
- Secrets in plaintext files or permissive env handling.
- No reliable telemetry to reconstruct events.
The pattern is consistent: convenience first, boundaries later. Reverse that order and most of the risk drops fast.
Hardening checklist (the one I actually run)
1) Keep access private by default
Use loopback/private networking first. Public exposure should be explicit and justified, not accidental.
# Verify listening endpoints
sudo ss -tlnp | grep -E '18789|18793'
Failure indicator: service listening broadly when you expected local-only.
2) Enforce auth and token discipline
If you use token auth, keep gateway and remote token values aligned and verified after restart.
openclaw config get gateway.auth.token --json
openclaw config get gateway.remote.token --json
openclaw gateway restart
Failure indicator: unauthorized (1008) errors or inconsistent auth behavior.
3) Harden the host baseline before touching agent config
Patch OS, reduce exposed services, lock SSH, remove anything not needed for runtime.
Failure indicator: unrelated host compromise gives attacker direct path into agent runtime.
4) Run as non-root, always
Use a dedicated unprivileged user. This alone reduces blast radius when something goes wrong.
# sanity check process user
ps aux | grep openclaw
5) Use tool allowlists, not broad execution
Default-deny dangerous capabilities. Add permissions only when tied to a documented workflow.
Failure indicator: untrusted input can trigger high-impact shell/file actions.
6) Require approvals for high-risk actions
External sends, destructive commands, and privileged changes should require human confirmation.
Failure indicator: high-impact actions can run unattended from natural-language prompts.
7) Protect secrets like production credentials
Don't leave keys in repos, scripts, or world-readable files. Use strict permissions and rotation ownership.
# example: check restrictive perms
ls -la ~/.openclaw/
chmod 600 ~/.config/openclaw/env
8) Isolate runtime when possible
Container/sandbox boundaries won't fix everything, but they reduce host-level impact from agent mistakes.
9) Treat external content as hostile by default
Website text, external emails, and public chat content should never be trusted as execution intent.
10) Lock down chat/bot integration scope
Use allowlists, narrow sender scope, and private channels only. Broad bot visibility is unnecessary risk.
Validation before go-live
I do a quick verification pass before calling a deployment "safe enough":
- Expected endpoints reachable, unexpected ones blocked
- Valid token succeeds, invalid token fails
- Approval gates trigger on risky actions
- Logs are actually written where expected
# valid token check
curl -H "Authorization: Bearer <token>" http://localhost:18789/health
# invalid token check (must fail)
curl -H "Authorization: Bearer wrong" http://localhost:18789/health
Minimum incident response playbook
If I suspect compromise, first hour priorities are straightforward:
- Revoke/rotate tokens immediately
- Disable high-risk tools
- Restrict network exposure to private path
- Preserve logs and config state for investigation
- Verify blast radius before re-enabling automation
Governance that keeps this stable
The checklist only works long-term if exceptions are controlled:
- Every exception has owner + expiry
- High-risk config changes are reviewed
- Weekly quick checks and monthly deeper review