Chapter 13
13 / 16

Security Best Practices

⏱️ 30 min

OpenClaw security does not begin with an impossible promise to block every prompt injection. First constrain who can trigger the agent and what the agent can do after it is triggered. The official security guide uses the same priority: lock down open DMs and groups, then review tools, network exposure, filesystem permissions, plugins and models.

Confirm the trust model

OpenClaw targets a personal-assistant trust model: one trusted operator boundary per Gateway. It is not a hostile multi-tenant isolation layer for unrelated users sharing one privileged agent.

If two users or organizations do not trust each other, split Gateways and credentials. Higher-risk deployments should also use separate OS users or hosts.

Risk factors multiply

External input × Available tools × Data scope × Automatic execution
                                           ↓
                                       Blast radius

A public room alone may not create an incident. A public room combined with shell, file and network write access gives misleading or malicious content real execution power.

Four layers to review

LayerReviewSafe baseline
EntryDMs, groups, pairing and allowlistsDeny unknown senders; require explicit group triggers
GatewayBind address, authentication and remote accessPrefer loopback; never expose an unauthenticated Gateway publicly
ToolsShell, filesystem, browser, network and cronMinimum privilege; ask before high-impact actions
DataConfig, credentials, logs and workspaceRestrict readable scope; never place secrets in skills or chat

Run the official security audit

After security-related configuration changes or before exposing a network surface:

openclaw security audit

Probe the running Gateway when needed:

openclaw security audit --deep

--fix applies deliberately narrow remediations. It cannot decide which permissions the business needs, so inspect the scope first:

openclaw security audit --fix

Permission matrix

Do not write “administrators may use every tool.” Record actions at a reviewable level:

ActionDefaultAllow conditionRollback
Read named workspaceAllowWorkspace paths onlyStop and record the accessed path
Modify a fileAskShow target and change summaryRestore from version history
Execute shellDenyApprove the exact commandTerminate process and preserve logs
Send an external messageAskShow recipient and final bodyStop later sends and notify operator
Create cron workAskRecord cadence, input and ownerDisable task and record last run

What pairing and allowlists do not solve

Pairing and allowlists control who can directly request work. They do not sanitize web pages, attachments, forwarded messages or tool results included in a trusted user's context.

Tool policy, workspace scope and automatic-execution rules are still required.

Review skills and plugins

Answer five questions before installation:

  1. Can you verify the source and maintainer?
  2. Which files, environment variables or credentials can it read?
  3. Which domains or external services can it contact?
  4. Does it execute scripts or install dependencies?
  5. After removal, how are credentials and scheduled work revoked?

If you cannot inspect the script, do not install it into a Gateway holding production credentials.

Practice: complete the security baseline

  • Gateway exposure is limited to the required network scope;
  • DM and group entry points use pairing or allowlists;
  • filesystem access is restricted to the named workspace;
  • shell, browser writes, messaging and cron default to deny or ask;
  • credentials do not appear in skills, prompts or log examples;
  • openclaw security audit has been run and recorded;
  • stop, rollback and operator-notification procedures are written.

Done means you can take any external input and identify the maximum data and action scope it can reach.

Official references