Security in the age of agentic AI is not about firewalls; it is about containment. When you deploy OpenClaw, you are not just running a chatbot. You are deploying an autonomous system that can execute code, modify files, and access the internet.
This guide is the definitive resource for securing a local OpenClaw deployment. It moves beyond basic advice to cover threat modeling, supply chain integrity, host hardening, and advanced sandboxing.
Whether you are running OpenClaw on a personal MacBook, a dedicated homelab server, or a corporate workstation, this guide will help you architect a deployment that is secure by design.
1. Understanding the Threat Model
To secure a system, you must first understand what you are defending against. OpenClaw’s threat model aligns with the OWASP Top 10 for LLM Applications, focusing on four primary attack vectors in a local deployment scenario:
The Four Core Threats
-
Prompt Injection & Indirect Injection:
- Attack: An attacker embeds hidden instructions in a website, email, or document that OpenClaw processes.
- Result: The agent is tricked into executing malicious commands, exfiltrating data, or modifying files without your consent.
- Defense: Strict tool policies, sandboxing, and human-in-the-loop (HITL) authorization for sensitive actions.
-
Supply Chain Compromise:
- Attack: A malicious actor compromises a third-party skill, plugin, or dependency (e.g., an npm package) that you install.
- Result: The compromised skill executes code on your machine, stealing credentials or establishing persistence.
- Defense: Pinning versions, reviewing code, using SBOMs, and rigorous plugin vetting.
-
Local Environment Compromise:
- Attack: Malware or a malicious insider on your local machine accesses OpenClaw’s storage.
- Result: Theft of API keys, session transcripts (which may contain sensitive PII), and authentication tokens.
- Defense: Full disk encryption, file permissions, and OS-level user separation.
-
Network Exposure:
- Attack: The OpenClaw Gateway (default port
18789) is accidentally exposed to the public internet or an untrusted LAN. - Result: Remote attackers gain control of the agent interface.
- Defense: Binding to loopback (
127.0.0.1), requiring authentication, and using VPNs/Tailscale for remote access.
- Attack: The OpenClaw Gateway (default port
2. Secure Installation & Supply Chain
Security starts before you even run the software. How you acquire and update OpenClaw defines your initial trust base.
The Risks of curl | bash
While the "one-liner" install is convenient, it pipes a network script directly to your shell. For a high-security deployment, avoid this method.
Recommended Installation Hierarchy:
- Reproducible Builds (Nix): Use the
nix-openclawflake for a fully deterministic, audit-friendly install. - Verified Release Tags: Download source or binaries from signed GitHub releases.
- npm with Vigilance: If installing via npm, treat it as a supply chain risk.
Dependency Management
OpenClaw plugins are effectively untrusted code execution.
- Pin Versions: Never use
latesttags. Pin dependencies to specific, audited versions in yourpackage.json. - Audit Signatures: Use
npm audit signaturesto verify registry integrity. - Minimal Footprint: Only install plugins you absolutely need. Every new skill expands your attack surface.
3. Host Hardening: The Foundation
Your agent is only as secure as the OS it runs on. If the host is compromised, the agent is compromised.
Essential OS Controls
- Full Disk Encryption (FDE): Ensure your drive (especially
~/.openclaw) is encrypted (FileVault on macOS, LUKS on Linux, BitLocker on Windows). This protects transcripts and keys if the device is stolen. - Dedicated User: Do not run OpenClaw as your daily driver user. Create a dedicated OS user (e.g.,
openclaw_user) with limited permissions. - Filesystem Permissions: Locking down the state directory is critical.
chmod 700 ~/.openclaw chmod 600 ~/.openclaw/config.yaml
Linux-Specific Hardening (AppArmor / SELinux)
For Linux deployments, use Mandatory Access Control (MAC) to confine the process. An AppArmor profile can restrict OpenClaw to reading/writing only its own directories, effectively neutralizing many "breakout" attacks even if the process is compromised.
4. Isolation & Sandboxing: The Last Line of Defense
If an attacker manages to inject a malicious command, sandboxing ensures that command executes in a disposable prison, not on your host machine.
Docker Sandboxing (Recommended)
OpenClaw supports native Docker sandboxing. This should be enabled for all deployments.
Configuration Best Practices:
- Network: Disable network access for the sandbox by default (
allow_network: false). If a skill needs the internet (e.g.,curl), explicitly allow it for only that skill. - Mounts: Never bind mount sensitive host directories (
/,/etc,/home/user) into the sandbox. Use a dedicated./workspacedirectory. - Read-Only Root: Run the container with a read-only root filesystem to prevent malware persistence within the container session.
Advanced Isolation: MicroVMs
For the paranoid (or enterprise), container isolation may not be enough. Technologies like Firecracker (MicroVMs) or gVisor (userspace kernel) provide hardware-level virtualization, ensuring that even a kernel exploit cannot breach the host.
5. Network Security & Remote Access
By default, OpenClaw listens on 127.0.0.1:18789. Keep it there.
The "Loopback Only" Rule
Never expose the raw API port to the public internet. Scanners will find it.
Secure Remote Access
If you need to access your agent remotely (e.g., from your phone):
- VPN / Tailscale: Use a private mesh network like Tailscale. This is the gold standard. It authenticates the device before it even reaches the application.
- SSH Tunneling:
ssh -L 18789:localhost:18789 user@host. Simple, encrypted, and robust. - Reverse Proxy with Auth: If you must expose it via HTTP, put it behind Nginx/Caddy with Mutual TLS (mTLS) or basic auth.
6. Access Control & Authorization
Authentication is not just for the network; it acts as an internal check on what the agent can do.
- Secure DM Mode: In multi-user environments (e.g., a shared Discord bot), enable "Secure DM Mode" to prevent users from accessing each other's session contexts.
- Tool Allow/Deny Lists: Explicitly allow only the tools required for a specific agent profile.
# Example: A safe "Researcher" profile allow: - browser_search - content_summary deny: - shell_execute - file_write - Confirmation (HITL): For high-stakes tools (
shell_execute,email_send), configure OpenClaw to require explicit user confirmation for every invocation.
7. Secrets Management: Protecting Your Keys
Your OPENAI_API_KEY is effectively a credit card with infinite limit. Storing it insecurely is a recipe for financial disaster.
The Hierarchy of Secret Storage
-
Environment Variables (Good):
- Store keys in a
.envfile, but never commit this file to Git. - Add
.envto your.gitignoreimmediately. - Use a template file (
.env.example) with dummy values for sharing.
- Store keys in a
-
OS Keyring / Secret Managers (Better):
- Instead of plaintext files, use your OS's native encrypted store (macOS Keychain, Linux Keyring, Windows Credential Manager).
- Tools like
keyring(Python) or usage of1Password CLI(op run -- openclaw ...) can inject secrets into the process environment at runtime without ever writing them to disk.
-
Filesystem Permissions (Critical):
- If you must use a config file (e.g.,
config.yaml), ensure it is readable only by the user running the agent. - Audit: Run
ls -l ~/.openclaw/config.yaml. If you see world-read permissions (-rw-r--r--), fix it immediately withchmod 600.
- If you must use a config file (e.g.,
Key Rotation Policy
Assume your keys will leak.
- Rotate Monthly: Generate new API keys and revoke old ones on a schedule.
- Usage Limits: Set hard monthly budget limits (e.g., $50) in your OpenAI/Anthropic dashboard. This is your kill switch.
8. The Ultimate Security Checklist
Before deploying OpenClaw in a production or always-on capacity, run through this checklist:
- Host: Full Disk Encryption enabled.
- User: Running as a dedicated, non-root user.
- Install: Installed via reproducible method or verified release.
- Config:
config.yamlpermissions set to600. - Secrets: API keys stored in env vars or secret manager (not hardcoded).
- Network: Gateway bound to
127.0.0.1. - Remote: Access accessible only via VPN/SSH.
- Sandbox: Docker mode enabled. Network disabled by default.
- Policies:
shell_executedenied or strictly scoped. - Audit: Regular review of
~/.openclaw/logsand session transcripts.
Conclusion
Security is a process, not a product. By following these guidelines, you transform OpenClaw from a potential liability into a hardened, enterprise-grade automation platform. The power of agentic AI lies in its ability to act—your job is to ensure it acts only as intended.




