














@@ -0,0 +1,212 @@
1+---
2+summary: "Pre-flight and rollback checklist before exposing an OpenClaw Gateway beyond loopback"
3+title: "Gateway exposure runbook"
4+sidebarTitle: "Exposure runbook"
5+read_when:
6+ - Exposing the Gateway over LAN, tailnet, Tailscale Serve, Funnel, or a reverse proxy
7+ - Reviewing a deployment before allowing real messaging users
8+ - Rolling back a risky remote access or DM configuration
9+---
10+11+<Warning>
12+Expose the Gateway only after you can explain who can reach it, how they are
13+authenticated, which agents they can trigger, and which tools those agents can
14+use. When in doubt, return to loopback-only access and re-run the audit.
15+</Warning>
16+17+This runbook turns the broader [Security](/gateway/security) guidance into an
18+operator checklist for remote access and messaging exposure.
19+20+## Choose the exposure pattern
21+22+Prefer the narrowest pattern that satisfies the workflow.
23+24+| Pattern | Recommended when | Required controls |
25+| -------------------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------- |
26+| Loopback + SSH tunnel | Personal use, admin access, debugging | Keep `gateway.bind: "loopback"` and tunnel `127.0.0.1:18789` |
27+| Loopback + Tailscale Serve | Personal tailnet access to Control UI/WebSocket | Keep Gateway loopback-only; rely on Tailscale identity headers only for supported surfaces |
28+| Tailnet/LAN bind | Dedicated private network with known devices | Gateway auth, firewall allowlist, no public port-forward |
29+| Trusted reverse proxy | Organization SSO/OIDC in front of Gateway | `trusted-proxy` auth, strict `trustedProxies`, header overwrite/strip rules, explicit allowed users |
30+| Public internet | Rare, high-risk deployments | Identity-aware proxy, TLS, rate limits, strict allowlists, sandboxed non-main sessions |
31+32+Avoid direct public port-forwarding to the Gateway. If you need public access,
33+put an identity-aware proxy in front of it and make the proxy the only network
34+path to the Gateway.
35+36+## Pre-flight inventory
37+38+Record these before changing bind, proxy, Tailscale, or channel policy:
39+40+- Gateway host, OS user, and state directory.
41+- Gateway URL and bind mode.
42+- Auth mode, token/password source, or trusted proxy identity source.
43+- All enabled channels and whether they accept DMs, groups, or webhooks.
44+- Agents reachable from non-local senders.
45+- Tool profile, sandbox mode, and elevated tool policy for each reachable agent.
46+- External credentials available to those agents.
47+- Backup location for `~/.openclaw/openclaw.json` and credentials.
48+49+If more than one person can message the bot, treat this as shared delegated tool
50+authority, not as per-user host isolation.
51+52+## Baseline checks
53+54+Run these before opening access:
55+56+```bash
57+openclaw doctor
58+openclaw security audit
59+openclaw security audit --deep
60+openclaw health
61+```
62+63+Resolve critical findings first. Warnings may be acceptable only when they are
64+intentional and documented for the deployment.
65+66+For remote CLI validation, pass credentials explicitly:
67+68+```bash
69+openclaw gateway probe --url ws://127.0.0.1:18789 --token "$OPENCLAW_GATEWAY_TOKEN"
70+```
71+72+Do not assume local config credentials apply to an explicit remote URL.
73+74+## Minimum safe baseline
75+76+Use this shape as the starting point for exposed deployments:
77+78+```json5
79+{
80+ gateway: {
81+ bind: "loopback",
82+ auth: {
83+ mode: "token",
84+ token: "replace-with-a-long-random-token",
85+ },
86+ },
87+ session: {
88+ dmScope: "per-channel-peer",
89+ },
90+ agents: {
91+ defaults: {
92+ sandbox: { mode: "non-main" },
93+ },
94+ },
95+ tools: {
96+ profile: "messaging",
97+ exec: { security: "deny", ask: "always" },
98+ elevated: { enabled: false },
99+ },
100+}
101+```
102+103+Then widen one control at a time. For example, add a specific channel allowlist
104+before enabling write-capable tools, or enable a reverse proxy before accepting
105+remote Control UI traffic.
106+107+The strict `exec.security: "deny"` baseline blocks all exec calls, including
108+benign diagnostics. If diagnostics or low-risk commands are required, relax this
109+only after choosing the specific senders, agents, commands, and approval mode
110+that match your threat model.
111+112+## DM and group exposure
113+114+Messaging channels are untrusted input surfaces. Before allowing DMs or groups:
115+116+- Prefer `dmPolicy: "pairing"` or strict `allowFrom` lists.
117+- Avoid `dmPolicy: "open"` unless every sender is trusted.
118+- Do not combine `"*"` allowlists with broad tool access.
119+- Require mentions in groups unless the room is tightly controlled.
120+- Use `session.dmScope: "per-channel-peer"` when multiple people can DM the bot.
121+- Route shared channels to agents with minimal tools and no personal credentials.
122+123+Pairing approves the sender to trigger the bot. It does not make that sender a
124+separate host security boundary.
125+126+## Reverse proxy checks
127+128+For identity-aware proxies:
129+130+- The proxy must authenticate users before forwarding to the Gateway.
131+- Direct access to the Gateway port must be blocked by firewall or network policy.
132+- `gateway.trustedProxies` must contain only the proxy source IPs.
133+- The proxy must strip or overwrite client-supplied identity and forwarding headers.
134+- `gateway.auth.trustedProxy.allowUsers` should list expected users when the proxy serves more than one audience.
135+- Same-host loopback proxy mode should use `allowLoopback` only when local processes are trusted and the proxy owns the identity headers.
136+137+Run `openclaw security audit --deep` after proxy changes. Trusted-proxy findings
138+are intentionally high-signal because the proxy becomes the authentication
139+boundary.
140+141+## Tool and sandbox review
142+143+Before exposing an agent to remote senders:
144+145+- Confirm which sessions run on host versus sandbox.
146+- Deny or require approval for host exec.
147+- Keep elevated tools disabled unless a specific, trusted sender needs them.
148+- Avoid browser, canvas, node, cron, gateway, and session-spawn tools for open or semi-open messaging surfaces.
149+- Keep bind mounts narrow and avoid credential, home, Docker socket, and system paths.
150+- Use separate gateways, OS users, or hosts for materially different trust boundaries.
151+152+If remote users are not fully trusted, isolation must come from separate
153+deployments, not only from prompts or session labels.
154+155+## Post-change validation
156+157+After each exposure change:
158+159+1. Re-run `openclaw security audit --deep`.
160+2. Test a successful authorized connection.
161+3. Test that an unauthorized sender or browser session is denied.
162+4. Confirm logs redact secrets.
163+5. Confirm DM/group routing reaches only the intended agent.
164+6. Confirm high-impact tools ask for approval or are denied.
165+7. Document the accepted residual warnings.
166+167+Do not proceed to the next exposure change until the current one is understood.
168+169+## Rollback plan
170+171+If the Gateway may be overexposed:
172+173+```json5
174+{
175+ gateway: {
176+ bind: "loopback",
177+ },
178+ channels: {
179+ whatsapp: { dmPolicy: "disabled" },
180+ telegram: { dmPolicy: "disabled" },
181+ discord: { dmPolicy: "disabled" },
182+ slack: { dmPolicy: "disabled" },
183+ },
184+ tools: {
185+ exec: { security: "deny", ask: "always" },
186+ elevated: { enabled: false },
187+ },
188+}
189+```
190+191+Then:
192+193+1. Stop public forwarding, Tailscale Funnel, or reverse proxy routes.
194+2. Rotate Gateway tokens/passwords and affected integration credentials.
195+3. Remove `"*"` and unexpected senders from allowlists.
196+4. Review recent audit logs, run history, tool calls, and config changes.
197+5. Re-run `openclaw security audit --deep`.
198+6. Re-enable access with the narrowest pattern that satisfies the workflow.
199+200+## Review checklist
201+202+- Gateway remains loopback-only unless there is a documented reason.
203+- Non-loopback access has auth, firewalling, and no public direct route.
204+- Trusted-proxy deployments have strict proxy IPs and header controls.
205+- DMs use pairing or allowlists, not open access by default.
206+- Groups require mentions or explicit allowlists.
207+- Shared channels do not reach personal credentials.
208+- Non-main sessions run in sandbox mode.
209+- Host exec and elevated tools are denied or approval-gated.
210+- Logs redact secrets.
211+- Critical audit findings are resolved.
212+- Rollback steps are tested and documented.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。