---
title: How to run OpenClaw safely: 10-step hardening guide · Airbox
description: Is OpenClaw safe? It can be. Ten steps from OpenClaw's own docs: a private gateway, DM pairing, the tool sandbox, tool limits, secrets on disk and the audit.
url: https://airbox.sh/guides/run-openclaw-safely
updated: 2026-11-16
---

# How to run OpenClaw safely.

OpenClaw reads your messages and acts on them, and it can run tools on the machine that hosts it. That's what makes it useful, and why the setup matters. These are the ten steps that keep it private, paired and contained, taken from OpenClaw's own security docs.

Updated November 16, 2026 · Checked against OpenClaw's docs

## The risks, in one minute

- **Anyone who can message it can try to steer it.** Every allowed sender can ask for tool calls, so who's allowed matters.
- **Content is a threat, not just senders.** Web pages, emails, attachments and pasted logs can carry hidden instructions, even if only you can DM the bot. OpenClaw's docs say plainly that prompt injection isn't solved.
- **Tools run on the host by default.** The sandbox is opt-in. Without it, tool calls run on the machine that hosts the gateway.
- **Its state holds secrets.** Anything under `~/.openclaw/` may contain credentials, including channel logins, model auth and session transcripts.
- **An exposed gateway is a door.** The gateway serves its Control UI and API on one port. Exposed without auth, that's remote control of your agent.

## 1. Give it a machine of its own

OpenClaw's docs call a dedicated host "not required, but recommended for reliability and isolation". A machine that holds nothing else, like a VPS or a spare Mac, means a mistake or an injected instruction can only reach the agent's own files. Your laptop, with your SSH keys, browser sessions and password manager, is the worst place for it.

For phone-number channels like WhatsApp, Signal and Telegram, the docs also suggest giving the bot its own number, so your personal conversations stay out of it.

## 2. Install it and keep Node.js current

OpenClaw needs Node.js 24.16+ or 26.1+, and its docs strongly recommend 24.22.1+ or 26.12.1+ for security. On Linux, Ubuntu LTS is the best-tested path.

*Terminal: installing OpenClaw and its gateway service*

```
$ curl -fsSL https://openclaw.ai/install.sh | bash
$ openclaw onboard --install-daemon
$ openclaw gateway status
```

## 3. Keep the gateway private

On a regular host the gateway binds to loopback, so only the machine itself can reach it, and it requires auth by default. Keep it that way, with a long random token (`openssl rand -hex 32` makes one):

*Config: gateway bound to loopback with token auth*

```
{
  gateway: {
    mode: "local",
    bind: "loopback",
    port: 18789,
    auth: { mode: "token", token: "your-long-random-token" },
  },
}
```

To open the Control UI from your laptop, tunnel to it instead of opening the port. Then visit `http://localhost:18789`:

*Terminal: SSH tunnel to the OpenClaw gateway*

```
$ ssh -N -L 18789:127.0.0.1:18789 you@your-server
```

The docs prefer Tailscale Serve over binding to your LAN, because Serve keeps the gateway on loopback. If you must bind beyond loopback, firewall the port to a tight list of source IPs, and never expose it unauthenticated on `0.0.0.0`. Read OpenClaw's exposure runbook before changing `gateway.bind`.

## 4. Control who can message it

Every DM channel has a `dmPolicy`:

| Policy | What it does | Use it? |
|---|---|---|
| `pairing` | The default. Unknown senders get a code that expires in an hour, and the bot ignores them until you approve. | Yes |
| `allowlist` | Unknown senders are blocked, with no pairing handshake. | Yes |
| `open` | Anyone can DM it. Needs `"*"` in the allowlist. | Not with tools |
| `disabled` | Ignores DMs entirely. | For group-only bots |

Approve people with `openclaw pairing list <channel>` and `openclaw pairing approve <channel> <code>`. In groups, require a mention so the bot only reads what's meant for it:

*Config: DM pairing and mention-gated groups*

```
{
  channels: {
    whatsapp: {
      dmPolicy: "pairing",
      groups: { "*": { requireMention: true } },
    },
  },
}
```

If more than one person can DM the bot, set `session.dmScope: "per-channel-peer"` so each person gets their own session instead of sharing the main one.

## 5. Turn on the tool sandbox

Sandboxing is off by default. When it's on, tool execution moves into a container (Docker is the default backend; Podman and SSH also work), while the gateway itself stays on the host.

*Config: sandbox every session with no workspace access*

```
{
  agents: {
    defaults: {
      sandbox: {
        mode: "all",            // or "non-main"
        scope: "session",
        workspaceAccess: "none", // or "ro" / "rw"
      },
    },
  },
}
```

Know what the modes cover. `"non-main"` sandboxes every session *except* the agent's main session, which is where your own DMs land by default. `"all"` sandboxes everything. Check what's actually in effect with `openclaw sandbox explain`. The docs are clear that a sandbox isn't a perfect boundary, which is why step 1 still matters.

## 6. Limit its tools

OpenClaw's hardened baseline starts from a messaging-only tool profile, denies the automation, runtime and filesystem groups, and requires approval for every command. Re-enable tools one agent at a time, only where you trust the inputs.

*Config: OpenClaw hardened tool baseline*

```
{
  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 },
  },
}
```

Keep `web_search`, `web_fetch` and `browser` off for tool-enabled agents unless you need them: they're the easiest way for untrusted content to get in. For mail and other untrusted inboxes, the docs suggest a read-only "reader" agent that summarizes, then hands the summary to your main agent.

## 7. Use a strong model for tool use

OpenClaw's docs say model choice "carries real weight" for prompt injection: smaller and older models are much easier to steer into misusing tools. Use the latest, best-tier model for any agent that can run tools or touch files and networks. A smaller model is fine for a chat-only assistant with trusted input and no tools.

## 8. Protect the secrets on disk

- Lock the state directory to your user: `chmod 700 ~/.openclaw` and `chmod 600 ~/.openclaw/openclaw.json`.
- Put provider keys in `~/.openclaw/.env` or the gateway's environment, not in a workspace `.env`. OpenClaw blocks provider keys in workspace `.env` files for this reason.
- Remember that session transcripts and file logs keep the original text, including any credentials that passed through them. Treat disk access as the trust boundary.

## 9. Run the security audit

OpenClaw ships its own checker. Run it after setup and after any config change, and fix critical findings first:

*Terminal: running OpenClaw's security audit*

```
$ openclaw security audit
$ openclaw security audit --deep
```

It flags things like a blank or short gateway token, an exposed bind and risky tool settings.

## 10. Plan for a bad day

Take snapshots or backups before risky work, so "the agent broke it" is a restore, not a rebuild. If you think the agent or gateway was compromised, OpenClaw's incident checklist comes down to:

1. **Contain:** stop the gateway, set `gateway.bind` back to `"loopback"`, switch risky DMs to `dmPolicy: "disabled"` and remove any `"*"` entries.
2. **Rotate:** the gateway token, remote client secrets, and every provider and channel credential.
3. **Audit:** check `openclaw logs` and the session transcripts, review recent config changes, and re-run `openclaw security audit --deep`.

## What no setup can do

Even a perfectly hardened OpenClaw acts with the permissions you give it. If it has a token that can send email or push code, an injected instruction can try to use it. Give it narrow, read-only credentials where you can, and remember that a snapshot restores the machine, not the messages it already sent.

**Want steps 1, 2, 3, 5, 8 and 10 done for you?** On Airbox, OpenClaw runs on a dedicated box on a current Node.js, with the gateway on loopback, the sandbox and DM pairing on, keys added at the network edge instead of on disk, and automatic snapshots. [Claim an OpenClaw box](https://airbox.sh/?agent=OpenClaw&plan=ab-4#signup) or read [how it works](https://airbox.sh/agents/openclaw).

## Questions

### Is OpenClaw safe to use?

It can be, if you set it up for it. Out of the box the gateway stays on loopback and unknown DMs get a pairing code, but the tool sandbox is off, so tools run on the host. Give it a dedicated machine, keep pairing on, turn the sandbox on, limit its tools and run openclaw security audit.

### Should I set dmPolicy to open?

Not for an agent that can run tools. With open, anyone can DM it, and every sender can try to steer what it does. Use pairing (the default) or allowlist.

### Does the non-main sandbox mode protect my own chats?

No. non-main sandboxes every session except the agent's main session, which is where your own DMs land by default. Use all to sandbox every session, or rely on the machine itself as the boundary for the main session.

### What port does OpenClaw use, and should I open it?

The gateway uses port 18789 by default. Don't open it to the internet. Keep it bound to loopback and reach the Control UI through an SSH tunnel or Tailscale Serve.

### What should I do if my OpenClaw gets compromised?

Stop the gateway, set it back to loopback and disable risky DMs. Then rotate the gateway token and every provider and channel credential, review the logs and session transcripts, and re-run openclaw security audit --deep.

Sources: OpenClaw's docs on [security](https://docs.openclaw.ai/gateway/security), [hardened baselines](https://docs.openclaw.ai/gateway/security/hardened-baseline), [access control](https://docs.openclaw.ai/gateway/security/access-control), [network exposure](https://docs.openclaw.ai/gateway/security/network-exposure), [sandboxing](https://docs.openclaw.ai/gateway/sandboxing), [prompt injection](https://docs.openclaw.ai/gateway/security/prompt-injection), [secrets and storage](https://docs.openclaw.ai/gateway/security/secrets-and-storage) and [incident response](https://docs.openclaw.ai/gateway/security/operator-incident-response), checked November 16, 2026. Config examples are adapted from those pages; check them against your installed version. Next: [OpenClaw hardware requirements](https://airbox.sh/guides/openclaw-requirements).

## Or skip the setup and claim a box.

[Claim an OpenClaw box · from $15/mo](https://airbox.sh/?agent=OpenClaw&plan=ab-4#signup)
