✕ Beranda Langganan Per Project Proses Profil FAQ Co-Researcher Blog Carousel SaaS Hubungi
Artikel ini juga tersedia dalam Bahasa Indonesia. Baca versi Indonesia →

Securing AI Agents on Your Server: Sandboxing, Permissions, Least Privilege

Securing AI Agents on Your Server: Sandboxing, Permissions, Least Privilege

Agents That Act, Not Just Answer

Today's AI agents do far more than reply to chat messages. Take OpenClaw, an open-source agent that runs on your own machine: it connects an LLM (Claude, GPT, Gemini, DeepSeek, or a local model) to your files, shell, browser, and dozens of messaging platforms. Its documentation describes it as an assistant that "actually does things", and its heartbeat system checks for pending tasks every 30 minutes and acts without being prompted.

That capability is exactly what makes it useful — and exactly what makes it dangerous when installed carelessly on a server. This article covers how to secure an AI agent on your own infrastructure using three principles: sandboxing, permissions, and least privilege.

1. Understand the Attack Surface

The core problem with AI agents is that one process holds many keys at once: shell access, file access, and credentials (model API keys, bot tokens, chat accounts). According to the OpenClaw docs, the agent "runs as your user — can read/write any file, execute any command." If the agent is tricked, every one of those keys is exposed.

This is not theoretical. The same documentation records 10 CVEs in 6 months, including a critical one-click RCE (CVE-2026-25253), 341 trojanized skills (about 12% of ClawHub) discovered in February 2026, and more than 40,000 gateways found open on the internet.

Access Example of abuse
Shell Running destructive commands or installing a backdoor
Files Reading .env files, SSH keys, or database dumps
Credentials Burning through API quota or messaging people as you
Network Strangers using an exposed gateway to command the agent

2. Non-Negotiable Ground Rules

Before reaching for advanced features, three rules are mandatory:

  • Never run it as root. The OpenClaw docs say so explicitly. Create a dedicated user with no sudo rights and its own home directory, so any mistake stays confined to that user.
  • Bind to localhost. The OpenClaw gateway listens on port 18789 by default. Do not expose it to the internet; if you need remote access, use an SSH tunnel or a VPN.
  • Enable gateway authentication. Set a token or put the gateway behind reverse-proxy authentication. An unauthenticated gateway is effectively a public shell.

The OpenClaw repository also applies default deny to direct messages: unknown senders must be paired and approved with openclaw pairing approve <channel> <code>. Keep that behaviour — every inbound message should be treated as untrusted input.

3. Graduated Permission Modes

OpenClaw offers three execution modes for shell commands:

Mode Behaviour Best for
ask Requests approval before each command Getting started, production servers
auto Executes without approval Isolated, well-tested environments
deny Blocks execution Agents that only need to read and answer

The recommendation is clear: start in ask mode and approve each shell command before it runs. The docs also advise starting with read-only permissions and expanding gradually. Move to auto only for task patterns you fully understand, and only inside an isolated environment.

This mirrors the Model Context Protocol (MCP) specification: hosts must obtain explicit user consent before invoking any tool, and users should understand what each tool does before authorizing its use.

4. Isolate with Containers or VMs

The OpenClaw repository explains that tools execute directly on the host for the main session unless sandboxing is configured. For high-risk work — running code pulled from the internet, processing files sent by others, or serving multiple users — the docs recommend a Docker container, the --container flag, or a VM.

Some common practices when building a Docker-based sandbox:

  • Mount only the working directory the task needs, read-only where possible.
  • Never mount the Docker socket or the host's home directory into the container.
  • Drop Linux capabilities (for example --cap-drop ALL) and restrict networking (--network none when the task needs no internet).
  • Inject only the credentials that specific task requires, not your entire .env.

For stronger isolation, such as an agent allowed to run arbitrary code, a separate VM gives you its own kernel boundary and is safer than a container.

5. Prompt Injection and Untrusted Tools

The sneakiest threat does not arrive through an open port — it arrives through content. A web page, an email, a GitHub issue, or a document can embed hidden instructions that make the agent do something other than what you asked. That is prompt injection.

The MCP specification states that tools represent arbitrary code execution and must be treated with appropriate caution. In particular, descriptions of tool behaviour, such as annotations, should be considered untrusted unless obtained from a trusted server. A tool that claims to be "read-only" may not be: its description is written by the server's author and can even contain instructions that manipulate the model.

The 341 trojanized skills on ClawHub show the risk is real. In practice:

  • Install skills or MCP servers only from sources you have audited.
  • Read the tool's code, not just its description.
  • Separate agents that read outside content from agents that hold important credentials.
  • Keep a human approval step for any irreversible action.

6. Audit Regularly

Security is not a one-time configuration. OpenClaw ships openclaw security audit --deep to check your setup; run it periodically, especially after upgrading or adding skills. The repository also notes that by default OpenClaw only phones home for a daily version check, anonymous feature statistics are opt-in, and both can be disabled with update.checkOnStart: false.

Conclusion

An AI agent on your server is essentially a new user who is extremely diligent, extremely fast, and easily persuaded. Treat it that way: give it its own non-root account, keep the gateway off the internet, require authentication, start in ask mode, isolate risky tasks in a container or VM, and never take a tool's description at face value. With least privilege, an agent's mistake stays a minor annoyance instead of a major incident.

References

Share Article