Security & Hardening

OpenClaw Security Best Practices: Hardening Your AI Agent Deployment

๐Ÿ“… February 20, 2026 โฑ 9 min read โœ๏ธ OptinAmpOut Team

OpenClaw gives AI agents real capabilities: shell execution, file system access, web browsing, tool extensibility. That power is the point. But it also means the security considerations are real โ€” these aren't chatbots constrained to answering questions, they're autonomous systems that can take actions.

We've operated production AI agents continuously for months. In the process, we've developed a layered security model that keeps deployments locked down without crippling agent effectiveness. This is what we've learned.

The model has three layers: built-in tool security (OpenClaw's policy system), hardened gateway configuration (how you expose and authenticate the gateway), and host-level hardening (the operating environment). All three matter. Weakness in any layer undermines the others.

Three-Layer Security Model
LAYER 3 โ€” HOST HARDENING Firewall ยท SSH ยท Secrets LAYER 2 โ€” GATEWAY CONFIG Bind ยท Auth ยท Hooks LAYER 1 โ€” TOOL SECURITY POLICY EXEC allowlist mode deny | ask | full FILE I/O scoped access workspace only BROWSER allowlist if needed deny if not used SUB-AGENTS isolated context for untrusted input Defense in depth โ€” each layer independent

Layer 1: Tool Security Policy

1Built-in Policy Engine

OpenClaw's tool policy system is your first line of defense. It controls what capabilities the agent has before any request is even processed. The fundamental principle: deny everything not explicitly needed.

Allowlisting vs. Denylist

The default tool policy in most configurations is permissive โ€” the agent has access to everything available. In production, flip this to an explicit allowlist:

{
  "tools": {
    "policy": "allowlist",
    "allowed": ["Read", "Write", "Edit", "exec", "web_search"],
    "denied": ["browser", "message", "nodes"]
  }
}

If your agent's job is to process documents and search the web, it has no reason to control a browser or send messages autonomously. Every capability that isn't required is an attack surface that doesn't need to exist.

Exec Security Modes

Shell execution is the highest-risk capability. OpenClaw's exec tool has three security modes:

ModeBehaviorWhen to Use
denyNo shell execution at allAgents that only read/write files
allowlistOnly commands matching explicit patterns runProduction default
fullAny command runs, no restrictionsNever in production
โš ๏ธ Never use full mode in production. It means a successfully injected prompt can run arbitrary shell commands. There is no legitimate production use case for it.

In allowlist mode, configure patterns that match only the commands your agent legitimately needs:

{
  "exec": {
    "security": "allowlist",
    "allowedPatterns": [
      "git *",
      "npm run *",
      "curl -s https://*",
      "bash skills/*"
    ]
  }
}

The Ask Mode: Your Oversight Valve

The ask parameter controls when the agent pauses for human confirmation before executing a command. In production we use on-miss: the agent runs freely within known-safe allowlist patterns, but anything that doesn't match triggers a confirmation prompt. This catches novel or unexpected commands before they run.

Exec Security Decision Flow
EXEC REQUEST Security Mode? deny BLOCKED always allowlist Matches pattern? yes EXECUTE runs safely no match ASK HUMAN (on-miss) full โš ๏ธ EXECUTE no checks

Layer 2: Hardened Gateway Configuration

2Gateway & Auth

The OpenClaw gateway is an HTTP server that accepts commands and returns results. How you configure it โ€” where it listens, how it authenticates, what it exposes โ€” is your second major defense layer.

Gateway Binding: The Most Important Decision

The bind setting controls which network interface the gateway listens on. Getting this wrong puts an unauthenticated (or weakly authenticated) AI agent control plane on a reachable network.

{
  "gateway": {
    "bind": "tailnet"   // or "loopback" โ€” never expose publicly
  }
}

Authentication Token Hygiene

Treat your gateway auth token like a root credential. Two rules without exceptions:

  1. Generate it randomly. Use your system's cryptographic random source โ€” openssl rand -hex 24 or equivalent. Not a password. Not a memorable phrase. 48+ hex characters of entropy.
  2. Store it in a secrets manager. Your config file should contain an environment variable reference, not the token itself. The actual token should live in an encrypted secrets store and be injected at runtime. If your config file ever appears in a log, a screenshot, or a git repo, you have not leaked your token.

Webhook Authentication

If you use OpenClaw's hook system for event-driven activation, each webhook endpoint needs its own bearer token, validated on every request. An unauthenticated webhook endpoint is an open prompt-injection surface โ€” any attacker who knows the URL can send payloads that wake your agent with arbitrary instructions.

Auth Settings to Verify

{
  "allowInsecureAuth": false,
  "dangerouslyDisableDeviceAuth": false
}

Both default to false. Both should stay false. If you find yourself wanting to set either to true, the correct response is to fix the underlying configuration issue, not to disable authentication safeguards.

Secure Gateway Architecture
INTERNET ๐ŸŒ Untrusted Public Traffic FIREWALL โœ• TAILSCALE VPN ๐Ÿ”’ Trusted Devices End-to-end encrypted Device authenticated Bearer Token GATEWAY bind: tailnet auth: token โœ“ insecureAuth: false hooks: validated AGENT scoped tools allowlist exec Gateway never reachable from public internet ยท All access via Tailscale mesh

Session Isolation for Untrusted Content

This is the hardening decision with the most operational impact: never process untrusted external content in your main agent session.

When an agent fetches a web page, reads a user-submitted document, or processes a third-party API response, that content may contain prompt injection payloads โ€” carefully crafted text designed to override the agent's instructions and redirect its behavior. A sub-agent spawned in isolation has no access to the main session's credentials, memory, or sensitive context. Even if a sub-agent is successfully compromised by an injected payload, the blast radius is contained to that isolated session.

Layer 3: Host-Level Hardening

3Operating Environment

The gateway configuration is only as secure as the host it runs on. Production deployments require host hardening as a baseline, not an optional extra.

Firewall Configuration

Apply a restrictive default-deny policy. The only inbound rule you need is SSH (ideally on a non-standard port). If you're using a mesh VPN for agent access, all agent traffic flows through that โ€” no additional firewall rules needed for it.

# Default deny all inbound
# Allow only: SSH on non-standard port
# All other agent traffic via VPN mesh โ€” no public ports needed

SSH Hardening

# sshd_config essentials:
PasswordAuthentication no
PermitRootLogin no
PubkeyAuthentication yes

Key-only authentication. No root login. If you follow these two rules and nothing else, you've eliminated the vast majority of automated SSH compromise attempts.

Secrets Management

Every secret your agent needs โ€” API keys, auth tokens, bot credentials โ€” should live in an encrypted secrets store (gopass, pass, HashiCorp Vault, or equivalent). The rule is simple: secrets in files can leak. Files end up in git repos, backups, logs, screenshots. An encrypted secrets store with GPG-backed storage means that even a full filesystem read doesn't expose credentials.

Your config files should contain environment variable references, not secrets. Secrets get injected at runtime from the secrets store. If a config file leaks, you've leaked nothing sensitive.

Memory Safety

Agent sessions accumulate context โ€” API responses, file contents, intermediate reasoning. Some of that content is sensitive. Use whatever mechanism your deployment offers to mark sensitive context as non-persistent: it should be available within the session for reasoning purposes, but not written to session logs or long-term memory.

Prompt Injection Defense: Sub-Agent Isolation
MAIN SESSION ๐Ÿ”‘ Credentials & API Keys ๐Ÿ“‹ Long-term Memory ๐Ÿ› ๏ธ Full Tool Access spawns SUB-AGENT (isolated context) โŒ No credentials โŒ No long-term memory โœ“ Can fetch/process fetches EXTERNAL CONTENT Web pages User submissions API responses โš ๏ธ May contain injection payloads returns sanitized result only โ€” no context leak

SecureClaw & IronClaw: The Hardened Variants

OpenClaw ships as a flexible platform. SecureClaw and IronClaw are hardened configuration profiles โ€” battle-tested setups that apply all the security principles above out of the box.

SecureClaw

SecureClaw is the security-focused OpenClaw variant maintained by the community at github.com/openclaw/openclaw. It ships with opinionated defaults: tool allowlisting enabled, exec security set to allowlist mode, and gateway binding restricted to loopback. Rather than configuring security from scratch, SecureClaw gives you a hardened baseline you can loosen โ€” not a permissive baseline you have to remember to tighten.

Key SecureClaw defaults:

IronClaw

IronClaw takes SecureClaw further โ€” it's the maximally hardened profile for deployments where security is the primary concern over convenience. IronClaw is appropriate for:

SecureClaw vs IronClaw: Feature Comparison
SECURECLAW IRONCLAW VANILLA OPENCLAW Exec mode Gateway bind Tool policy Insecure auth Sub-agent isolation Secrets enforcement allowlist loopback minimal blocked encouraged recommended deny (default) loopback only deny-all default forced off required enforced full (default) 0.0.0.0 all tools configurable optional manual Secure default Recommended Requires hardening

Which Should You Use?

Use SecureClaw as your starting point for any production deployment. It applies sane defaults without eliminating flexibility. Use IronClaw when you need the maximum security posture โ€” accepting the tradeoff that some capabilities require explicit opt-in configuration.

Vanilla OpenClaw is appropriate for local development and exploration where security is not a concern. It should never be the configuration for a deployment that has access to real credentials, production systems, or external network access.

Advanced: Reverse Tunnel Architecture

When running an agent on a device that lacks a stable public address โ€” a mobile device on cellular, a machine behind NAT โ€” a reverse SSH tunnel provides secure remote access without exposing anything directly.

The pattern: the agent device initiates an outbound SSH connection to a stable endpoint (a laptop or server on your VPN), and creates a port-forward that maps a port on that endpoint back to the agent's gateway. Access to the agent flows through the SSH tunnel, which authenticates via key pair and benefits from the endpoint's own firewall rules.

Reverse Tunnel: Mobile Agent Accessibility
MOBILE DEVICE ๐Ÿ“ฑ Gateway: loopback autossh persistent SSH tunnel (outbound, key auth) STABLE ENDPOINT (laptop / server) ๐Ÿ’ป localhost:port forward Tailscale only TRUSTED CLIENTS Via Tailscale VPN ๐Ÿ–ฅ๏ธ ๐Ÿ“Ÿ ๐Ÿ”ง Only reachable from authenticated VPN peers Mobile gateway never directly exposed ยท Tunnel authenticated by SSH key ยท autossh auto-reconnects on drop

Key security properties of this pattern:

Monitoring for Anomalies

Security is not a one-time configuration. An agent operating in production needs ongoing monitoring:

Security Checklist

โœ… Before Going to Production

  • Gateway bound to loopback or VPN interface โ€” never to a public address
  • Auth token generated with a cryptographic random source (not a password)
  • Auth token stored in an encrypted secrets manager, not in config files
  • allowInsecureAuth: false confirmed
  • dangerouslyDisableDeviceAuth: false confirmed
  • Exec security mode: allowlist โ€” command patterns explicitly defined
  • Tool policy: all unnecessary tools removed from the allowlist
  • SSH: key-only authentication, password auth disabled
  • Host firewall: default-deny inbound, minimal explicit allow rules
  • All API keys in secrets manager โ€” not in environment files committed to version control
  • Webhook tokens distinct from gateway tokens
  • Untrusted external content processed in isolated sub-agents
  • Session transcripts reviewed periodically for unexpected patterns
  • API billing alerts configured

AI agents with real capabilities require real security discipline. The good news is the threat model is well-understood: minimize exposed surface, authenticate everything, isolate untrusted inputs, monitor for anomalies. These are the same principles that govern any privileged system โ€” applied to a new category of software.

We've operated this setup in production for months with no security incidents. The investment in correct configuration is modest compared to the cost of a compromise.

Building production AI agent infrastructure? Get in touch โ€” we specialize in secure, production-grade agentic AI deployments.

๐Ÿข
FREE

Enterprise AI Security Checklist

Deploying AI at scale? Start with this enterprise security checklist.
No spam. Unsubscribe anytime.

โ†‘