Este artigo está disponível apenas em inglês.

By UNST33R

OpenClaw security hardening: contain an agent you can DM

OpenClaw is a 395,000-star gateway that connects WhatsApp, Discord, Telegram, Slack and more to AI coding agents with shell access. Its own security docs define the honest boundary: everyone who can message a tool-enabled agent shares its delegated authority. A four-layer hardening walkthrough built from the official docs, with copy-paste configs, the sandbox denylist internals, the audit command, and how to wire a per-engagement model layer behind it.

OpenClaw sits at 395,008 GitHub stars at our November 22 capture, with release 2026.11.6 published November 19. The pitch explains the growth: one self-hosted gateway process connects WhatsApp, Discord, Telegram, Signal, Slack, iMessage, Teams, and more to AI coding agents, so your assistant is a DM away from anywhere. For a security team, that sentence reads differently. A coding agent is a process that reads files, writes code, and runs commands. A chat platform is a control plane that anyone with your phone number or a group invite can reach. The engineering question is containment, and OpenClaw's security documentation is unusually direct about what you are actually buying.

This walkthrough assembles the hardening path from those docs, in the order the layers fail: who can reach the agent, what the agent may call, where its code runs, and where its plugins come from. It ends with the model-layer wiring for teams running authorized offensive tooling through OpenClaw. The OpenClaw alternatives comparison and the site's OpenClaw guide cover the model-selection side; this post covers the containment side.

The trust boundary you actually get

The security trust model page states the design constraint without hedging: one trust boundary per gateway. A single operator, or a team whose members already trust each other with everything the agent can do. The load-bearing sentence, quoted from that page:

Everyone who can message a tool-enabled agent shares that agent's delegated tool authority. That is fine for teammates who already trust each other; it is why adversarial users cannot share an agent.

The defaults are conservative, and the docs enumerate the exceptions. A regular host install binds the gateway to loopback. Most chat channels answer unknown DM senders with a pairing code instead of processing the message. Group access is allowlisted behind a mention gate. The documented exceptions are container images defaulting to an exposed bind, covered by the exposure runbook, and a few workspace channels that trust workspace membership. Session tools are gateway-wide by default: tools.sessions.visibility starts at all and agent-to-agent messaging starts enabled, so any unsandboxed tool-enabled agent can read every other agent's transcripts. That is a documented property of a one-boundary design, and the rest of this post is about narrowing it deliberately.

Layer 1: who can talk to it

The access control docs define a dmPolicy per channel, and the differences matter more than they look:

PolicyBehavior
pairingDefault. Unknown senders get a pairing code; codes expire after 1 hour; pending requests capped at 3 per channel
allowlistUnknown senders blocked outright, no handshake
openAnyone can DM; requires the channel allowlist to include "*" as an explicit opt-in
disabledInbound DMs ignored entirely

Pairing is the right default for a personal deployment. For an agent that touches engagement infrastructure, allowlist is the better terminal state, because it removes the social-engineering surface of a pairing prompt appearing on your phone at the wrong moment. Groups get two independent allowlists: which groups the bot joins at all, and who may trigger it inside a group, with requireMention: true as the attention gate. Slash commands follow the same logic through commands.allowFrom; if a channel allowlist is empty or contains "*", commands are open for that channel. The pairing reference lists where approval state lives, by default ~/.openclaw/state/openclaw.sqlite.

One decision precedes all of this: which number, and which workspace. The docs suggest running phone-number channels on a separate number from your personal one, so the automation boundary is visible in the contact list rather than buried in config.

Layer 2: what the agent may call

The hardened baseline is a copy-paste starting point, and its tools block is the heart of it:

{
  tools: {
    profile: "messaging",
    deny: ["group:automation", "group:runtime", "group:fs", "sessions_spawn", "sessions_send"],
    fs: { workspaceOnly: true },
    exec: { security: "deny", ask: "always" },
    elevated: { enabled: false },
    sessions: { visibility: "agent" },
    agentToAgent: { enabled: false },
  },
}

Each key answers a specific failure. The deny list removes the control-plane tools: gateway (config reads that can expose secrets, updates, restarts) and cron (scheduled jobs that outlive the chat session), both owner-only by built-in policy for chat-driven turns, plus session spawning and cross-session messaging. sessions.visibility: "agent" and agentToAgent.enabled: false undo the gateway-wide defaults from the trust-model section. exec.security: "deny" with ask: "always" means code execution requests fail closed and surface to a human when re-enabled selectively.

Cross-provider messaging deserves its own look. Agents with message-tool access can send across conversations and providers by default: a WebChat session can message a configured Discord channel unless you turn it off. tools.message.crossContext exposes allowAcrossProviders and allowWithinProvider, both defaulting to true; set both to false to confine guarded message actions to the current conversation. For a red-team deployment this closes an exfiltration-adjacent path, since a compromised agent turn could otherwise relay content through any channel it can reach.

The tool permissions page adds a subtlety worth internalizing: requester-scoped controls evaluate the originating sender, and they do not sanitize other content in the prompt. Quoted text, forwarded messages, fetched pages, and tool results from untrusted sources still influence an owner-triggered turn. The docs frame these controls as defense in depth against direct capability, with genuine adversarial isolation requiring separate gateways and separate hosts. That framing matches how we teach prompt injection testing: content filters reduce abuse risk, and policy boundaries carry the security load.

Layer 3: where the code runs

The sandboxing doc offers two complementary approaches: run the entire gateway in Docker as a container boundary, or keep the gateway on the host and sandbox tool execution per agent through the built-in Docker and Podman backends. The per-agent settings have sharp edges worth knowing as an operator and as an assessor:

  • agents.defaults.sandbox.scope at "agent" (default) or "session" isolates per agent or per session; "shared" puts everyone in one container and workspace.
  • workspaceAccess defaults to "none", meaning sandboxed tools see only a sandbox workspace under ~/.openclaw/sandboxes and the agent workspace is off-limits; "ro" mounts it read-only at /agent and disables write tools; "rw" mounts it read-write.
  • Extra sandbox.docker.binds pass through a normalized-path denylist: /etc, /proc, /sys, /dev, /root, /boot, directories that alias the Docker socket, and home credential subpaths including .aws, .docker, .gnupg, .netrc, .npm, and .ssh. Symlink resolution re-checks ancestors, so parent-directory tricks that resolve into a blocked root are still rejected.
  • tools.elevated is the documented escape hatch that runs exec outside the sandbox. The guidance is blunt: keep allowFrom tight and do not enable it for strangers.

Node pairing is the sharpest edge in the whole model, and the docs label it exactly: "If a macOS node is paired, the Gateway can invoke system.run on it - this is remote code execution on that Mac." Pairing establishes device identity and issues a token, and it is a trust decision rather than a per-command approval surface. The boundary that remains after pairing is the gateway's global node command allow/deny list plus the node's own exec approvals file. For deployments that do not need it, the disabling sequence is explicit: set security to deny and remove the pairing.

Exec approvals themselves bind exact request context and, where possible, one concrete local file operand; when the runtime cannot identify exactly one direct local file for an interpreter command, approval-backed execution is denied. The docs are careful to call approvals a guardrail for operator intent, with sandboxing and host isolation doing the strong-boundary work. Read-only profiles assemble from the same parts: workspaceAccess: "ro" or "none", plus deny lists covering write, edit, apply_patch, exec, and process.

Layer 4: where the plugins come from

Plugins run in-process with the gateway, and the docs say to treat them as trusted code. The supply-chain controls are therefore about provenance decisions, made before install:

  • ClawHub packages and the bundled catalog are trusted sources; arbitrary npm, git, local, or archive sources warn interactively, and noninteractive installs require --force after you review and trust the source.
  • security.installPolicy runs a local operator command that returns allow, warn, or block for skill and plugin installs, applied after staging and before commit, including ClawHub skills.
  • ClawHub security audits publish per-package audit results you can read before installing.
  • Pin exact versions (@scope/pkg@1.2.3) and inspect unpacked code before enabling. Skill folders refresh mid-session via the watcher, so treat write access to them as equivalent to code execution.

This is the same discipline our multi-agent harness attack surface review and MCP tool poisoning drill prescribe for any agent extension mechanism: the plugin tier is code execution you opted into, and the audit trail is the only thing that makes it reviewable later.

The audit and the incident path

One command tells you whether a deployment has drifted from the safe baseline:

openclaw security audit

The audit checks page documents what it inspects, including the dangerous-flag inventory tracked across the network-exposure surface. When something does go wrong, the operator incident response guide follows the contain-rotate-collect order, and the secrets and storage page covers where the material you are rotating actually lives. Run the audit before and after any exposure change, which is what the exposure runbook formalizes as a pre-flight and rollback checklist.

The model layer, and the engagement wiring

Containment narrows what a compromised turn can reach. The model layer decides what that turn costs and where its prompts live. Custom providers accept custom endpoints and base URLs, so per-engagement isolation at the inference tier is one provider entry: point the agent at a dedicated key, and engagement A's transcripts and spend never share a bucket with engagement B. The tier economics for security workloads:

TierPricing per 1M tokensFits in an OpenClaw deployment as
unst33r-deepseek$0.15 in / $0.5625 out, $0.03125 cachedBulk loops: log triage, corpus scans, long unattended automations
unst33r-flash$0.50 in / $1.50 outInteractive chat-driven sessions where latency and tool-call reliability dominate
unst33r-pro$2.50 in / $4.50 outExploit-chain reasoning, report drafting, the turns a client reads

A cron-driven nightly summarizer chewing two million input tokens costs $0.30 on the deepseek tier; the same habit on the pro tier is $5.00 per run. The tier selection guide has the full workload mapping, and current prices live on the pricing page. Everything here assumes authorized use under the acceptable-use policy.

The checklist, condensed

LayerControlTerminal state for offensive work
ReachdmPolicy, group allowlists, requireMentionallowlist on every channel; mention-gated groups; separate number
ToolsBaseline deny, sessions.visibility, agentToAgent, crossContextBaseline deny list applied; cross-provider messaging off
ExecutionSandbox scope, workspaceAccess, elevated, node pairingSandboxed, workspaceAccess: "ro", elevated disabled, no paired nodes
Supply chaininstallPolicy, pinned versions, ClawHub auditsPolicy returns warn or block; no unpinned sources
Operationsopenclaw security audit, exposure runbookClean audit; runbook followed on every exposure change

OpenClaw earned its adoption by making the agent available everywhere. The hardening work is choosing, config by config, which parts of "everywhere" you meant.