Why this matters
Most AI tools can only talk. OpenClaw can act. It runs a browser, executes commands, and reaches out to web services. That's the entire appeal, and it's also the entire risk. An agent with exec access is one bad instruction away from running something you didn't mean to run.
The numbers from early 2026 made this concrete: tens of thousands of instances were found exposed to the public internet with bad defaults, and a chunk of those were already fully compromised. I don't bring this up to scare you off. I bring it up because the fix is mostly a handful of config choices, not a PhD.
What the gateway is
The gateway is OpenClaw's boundary between your agent and the outside world. Instead of opening the agent directly to incoming traffic, you funnel external triggers (webhooks, mostly) through the gateway, which handles authentication and scopes what's allowed in. Think of it as the front door instead of leaving every window open.
Running the agent on your laptop or a box on your home network is already safer than a public VPS, but only if the gateway is doing its job. A private network doesn't help if the thing is still listening on every interface.
The rules I follow
These are the settings I treat as non-negotiable:
- Never bind to 0.0.0.0. Bind to localhost and expose only the gateway, never the raw agent.
- Turn on authentication. Every webhook and external trigger needs a token or signature check. No anonymous entry points.
- Use the sandbox. Let tools run isolated so a bad command can't touch the host's files or secrets.
- Keep credentials in a vault. Don't drop API keys into plaintext config files that the agent itself can read.
- Run with least privilege. The agent doesn't need root. Give it a dedicated user with just enough access.
There's also a non-config rule that matters more than people admit: don't hand the agent credentials to anything you couldn't afford to lose. It's not a question of whether the model is trustworthy, it's that a tool with exec access can be steered somewhere you didn't intend.
Prompt injection
Here's the uncomfortable part: prompt injection is unsolved. Anyone can put text in a web page, an email, or a message that tries to talk your agent into doing something it shouldn't. There is no silver bullet config that makes this go away.
What you can do is raise the cost of an attack. Use a strong model that's harder to steer, keep high-impact actions (money, deletes, sending external messages) behind explicit approval, and never let the agent decide on its own to run destructive commands. The gateway and sandbox are your real backstops here, because even if the agent gets tricked, the damage it can do stays inside the box.