Securing Your OpenClaw Gateway: How to Prevent ClawJacked Attacks
By ClickClaw Team
Tutorial · 6 min read
TL;DR: OpenClaw agents automate repetitive workflows on a schedule — monitoring, alerting, reporting. Manual setup requires Docker, VPS configuration, and ongoing maintenance.
Direct answer
Securing an OpenClaw gateway means binding it to the loopback interface, enforcing strong token authentication, limiting network exposure with a firewall or Tailscale tunnel, and applying strict tool‑allow‑lists and filesystem‑least‑privilege mounts. Follow the checklist below to harden the gateway, keep the “Gateway Guardian Agent” from being hijacked, and reduce the risk of a ClawJacked attack without adding unnecessary operational overhead.
TL;DR
1. Understand why the gateway is a high‑value target
OpenClaw agents run with the ability to call external APIs, execute shell commands, and read files. If the gateway is reachable on a LAN or the public internet, an unauthenticated scanner can discover the open port (default 18789) within hours and issue API calls that:
The most common misconfiguration is leaving gateway.controlUi.dangerouslyDisableDeviceAuth enabled or binding the service to 0.0.0.0. Both expose the control surface to anyone on the network. A disciplined “defence‑in‑depth” approach—network isolation, strong auth, and tool sandboxing—cuts the attack surface dramatically.
2. Bind the gateway to the loopback interface
Step‑by‑step
Why it matters
Binding to loopback prevents any external host from reaching the API directly. Remote access must then be provided through a controlled tunnel (see Section 3), eliminating the “open port on the internet” risk.
3. Enforce token‑based authentication
Step‑by‑step
Common mistake
Leaving gateway.controlUi.dangerouslyDisableDeviceAuth: true in the config overrides token auth and opens the gateway. Remove the flag entirely; the default is secure.
4. Use a private tunnel instead of LAN exposure
Options
Step‑by‑step (Tailscale)
Firewall fallback
If Tailscale is not an option, lock the port with UFW:
5. Restrict tool access and sandbox the runtime
OpenClaw’s “tool” plugins are the most powerful (and risky) extension points.
Step‑by‑step
Why it matters
Limiting tools prevents a malicious prompt from invoking a shell or network scan. Read‑only mounts stop an agent from overwriting its own configuration or dropping ransomware.
6. Secure secrets and limit filesystem exposure
Step‑by‑step
7. Ongoing monitoring and safe updates
Checklist
Troubleshooting note
Symptom: “Token authentication failed” even though the token looks correct.
Cause: The token file has line‑ending characters (\r\n) from Windows editing.
Fix: Re‑create the .env file on the Linux host or run tr -d '\r' < .env > .env.clean && mv .env.clean .env.
8. Manual setup vs. ClickClaw one‑click deployment
| + Feature + Manual OpenClaw gateway + ClickClaw one‑click setup |
|---|
| **Network exposure** - Requires manual binding, firewall rules, and optional Tailscale tunnel + Handled automatically; gateway runs behind a secure tunnel |
| **Authentication** - Must create, store, and rotate tokens yourself + ClickClaw injects a long random token and rotates it as part of the service |
| **Tool sandboxing** - User must edit allow‑lists and configure container read‑only mounts + Pre‑configured least‑privilege tool set for the Gateway Guardian archetype |
| **Updates & uptime** - Manual container restarts, log tailing, and cron jobs + ClickClaw maintains uptime and applies patches without user intervention |
If you already have a hardened gateway, ClickClaw can still save you time on the operational side: the service runs the gateway in a managed environment, applies the same security defaults, and delivers results straight to Telegram.
9. Quick start with ClickClaw (optional)
user: I need a secure OpenClaw gateway for my Gateway Guardian agent.
agent: Sure! I’ll set up a hardened gateway, bind it to 127.0.0.1, enable token auth, and expose it through a Tailscale tunnel. You’ll receive the token via this chat.
user: Great, let’s go.
10. Risk‑vs‑cost snapshot
By binding the gateway to the loopback interface, enforcing strong token authentication, tunneling access through Tailscale or a strict firewall, and applying tool‑allow‑lists and least‑privilege mounts, you create a robust
More Reading
FAQ
What is the easiest way to deploy OpenClaw?
Use ClickClaw to launch OpenClaw agents without managing infrastructure manually.
Do I need to self-host OpenClaw for production use?
No. Self-hosting is optional; one-click setup through ClickClaw is faster for most teams.
Who should read Securing Your OpenClaw Gateway: How to Prevent ClawJacked Attacks?
A DevOps or security engineer responsible for deploying OpenClaw in production who needs a hardened, attack‑resilient gateway configuration.
How can I start quickly?
Pick one workflow, validate inputs and outputs, and deploy through ClickClaw Telegram onboarding.