OpenClaw Security Best Practices: How to Deploy AI Agents Without Exposing Your Organization
OpenClaw's rapid adoption has outpaced its security defaults. Learn how to lock down network bindings, manage secrets, enforce least privilege, vet third-party skills, and monitor agent activity to keep your deployment secure and compliant.
TL;DR
| Best Practice | Why It Matters |
|---|---|
| Bind to localhost only | Default 0.0.0.0 binding exposed 135,000+ instances to the public internet |
| Use a secrets manager | Config files store gateway tokens and API keys in plaintext by default |
| Enforce least privilege | Unrestricted tool access gives the agent full shell, filesystem, and browser control |
| Vet every skill you install | 820+ malicious skills were found on ClawHub, OpenClaw's official marketplace |
| Enable logging and monitoring | Without audit trails, you cannot detect or investigate agent misuse |
| Run the built-in security audit | One command flags misconfigurations, permission issues, and policy drift |
| Align with compliance frameworks | AI agents are privileged service accounts that auditors are starting to scrutinize |
Quick Answer: OpenClaw is a powerful open-source AI agent, but its default configuration prioritizes convenience over security. With over 135,000 exposed instances, a critical RCE vulnerability (CVE-2026-25253), and hundreds of malicious skills in its marketplace, teams need to actively harden their deployments. This guide walks through seven concrete best practices, each with specific configuration examples, to help you run OpenClaw securely and stay compliant.
OpenClaw has become the most popular open-source AI agent platform in a matter of months, crossing 247,000 GitHub stars since its November 2025 launch. Teams use it to automate workflows across email, calendars, messaging platforms, and cloud services, all from a self-hosted, local-first architecture.
But that rapid adoption has come with serious security incidents. In February 2026, researchers documented the first AI agent infostealer attack, where Vidar malware exfiltrated gateway tokens, cryptographic keys, and behavioral guidelines from OpenClaw installations. SecurityScorecard found over 135,000 exposed instances across 82 countries. And more than 820 malicious skills were discovered on ClawHub, OpenClaw's official marketplace.
The good news: OpenClaw provides the configuration knobs to lock things down. Most organizations just haven't turned them yet.
Here are seven security best practices every team should implement before, or immediately after, deploying OpenClaw.
1. Lock Down Network Bindings
The problem: OpenClaw's default configuration binds the gateway to 0.0.0.0:18789, which means it listens on all network interfaces, including the public internet. This is the single biggest reason SecurityScorecard found 135,000+ exposed instances, with 12,812 directly exploitable via remote code execution.
The fix: Bind the gateway to localhost only and enable authentication.
{
gateway: {
mode: "local",
bind: "loopback",
auth: { mode: "token", token: "replace-with-a-long-random-token" }
}
}
Key recommendations:
- Set
gateway.bindto"loopback"so the gateway only accepts connections from your local machine - Enable
gateway.authwith either"token"or"password"mode, never leave it unauthenticated - If you need remote access, use a VPN or Tailscale rather than exposing the port directly
- Disable mDNS broadcasting to prevent network discovery by setting
discovery.mdns.modeto"off"or using the environment variableOPENCLAW_DISABLE_BONJOUR=1
If you must use a reverse proxy, configure trustedProxies explicitly and ensure your proxy overwrites (not appends) the X-Forwarded-For header to prevent IP spoofing.
2. Manage Secrets Properly
The problem: OpenClaw stores sensitive data in plaintext config files on disk by default. The openclaw.json file contains your gateway token. The device.json file holds cryptographic keys. Channel credentials sit in ~/.openclaw/credentials/. Any infostealer, compromised dependency, or file-reading vulnerability can grab these in seconds.
The fix: Treat agent configuration files like SSH keys or API tokens.
Set proper filesystem permissions:
chmod 700 ~/.openclaw/
chmod 600 ~/.openclaw/openclaw.json
chmod 700 ~/.openclaw/credentials/
chmod 700 ~/.openclaw/agents/*/
Use environment variables for sensitive values:
export OPENCLAW_GATEWAY_PASSWORD="your-strong-password"
export OPENCLAW_GATEWAY_TOKEN="your-long-random-token"
Key recommendations:
- Never commit
openclaw.json,device.json, orsoul.mdto version control. Add them to.gitignore - Use a secrets manager (HashiCorp Vault, AWS Secrets Manager, or 1Password CLI) to inject credentials at runtime rather than storing them on disk
- Use scoped, read-only tokens wherever possible. If the agent only needs to read from an API, do not give it write access
- Prefer short-lived credentials over long-lived ones, and rotate them on a regular schedule
- If your agent has a memory feature, verify it never persists secrets in conversation history or session transcripts
For a deeper dive on this topic, see our guide on secrets management for startups.
3. Enforce Least Privilege for Tool Access
The problem: OpenClaw can execute shell commands, read and write files, control a browser, schedule cron jobs, spawn sub-agents, and more. Out of the box, many of these capabilities are enabled, giving the agent a broad attack surface if compromised.
The fix: Default to deny, then explicitly allow only the tools your use case requires.
{
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 }
}
}
Key recommendations:
- Start with the
"messaging"tool profile, which provides a restricted baseline, then add specific tools as needed - Deny
group:automation(cron/scheduling),group:runtime(code execution), andgroup:fs(filesystem operations) unless your workflow explicitly requires them - Set
exec.securityto"deny"andexec.askto"always"so the agent cannot run shell commands without explicit approval - Keep
elevatedmode disabled. This prevents the agent from performing host-level execution when its sandbox is unavailable - Restrict filesystem access to the workspace directory only with
fs.workspaceOnly: true - Block
sessions_spawnandsessions_sendto prevent the agent from delegating tasks to sub-agents without your knowledge
For multi-agent setups, create separate agent profiles with different permission levels. A public-facing agent should have far fewer permissions than your personal automation agent.
4. Vet Third-Party Skills Before Installing
The problem: ClawHub, OpenClaw's official skill marketplace, suffered a massive supply chain poisoning campaign. Security audits found 820+ malicious skills out of 10,700 total, and 36% of all listed skills contained detectable prompt injection. Malicious skills delivered infostealers, exfiltrated credentials to external webhooks, and hid reverse shell backdoors inside functional code.
The fix: Treat skill installation like adding a dependency to your production codebase.
{
plugins: {
allow: ["@scope/trusted-plugin@1.2.3"]
}
}
Key recommendations:
- Audit every skill's source code before installation, especially looking for suspicious network calls, filesystem access, or credential reads
- Use explicit allowlists in your configuration. Only install skills from verified publishers with established track records
- Pin exact versions to prevent supply-chain attacks via malicious updates
- Review unpacked skill code in
~/.openclaw/extensions/before enabling - Restart the gateway after any plugin change to ensure clean state
- Watch for typosquatted skill names, one of the primary attack vectors in the ClawHavoc campaign
This mirrors the same discipline you should apply to npm dependencies and any other third-party code.
5. Enable Logging and Monitoring
The problem: Without an audit trail, you have no visibility into what the agent is doing, what commands it executes, what data it accesses, or whether an attacker has taken control. Session transcripts and logs are your only forensic evidence during an incident.
The fix: Enable log redaction, retain transcripts, and integrate with your existing monitoring stack.
{
logging: {
redactSensitive: "tools",
redactPatterns: [
"sk-[a-zA-Z0-9]+",
"ghp_[a-zA-Z0-9]+",
"internal\\.yourcompany\\.com"
]
}
}
Key recommendations:
- Keep tool redaction enabled (the default) to prevent secrets from appearing in logs
- Add custom redaction patterns for your organization's tokens, internal hostnames, and API keys
- Regularly prune old session transcripts stored in
~/.openclaw/agents/<agentId>/sessions/*.jsonlto limit exposure if the filesystem is compromised - Forward agent logs to your SIEM or centralized logging platform for correlation with other security events
- When sharing diagnostics or asking for support, always use
openclaw status --all, which produces redacted output - Monitor for unusual patterns: unexpected outbound network connections, large file reads, or commands executed outside normal hours
6. Run the Built-In Security Audit Regularly
The problem: Configuration drift is real. Settings change, new skills get installed, permissions get loosened for "quick tests" and never tightened back. Without regular checks, your hardened configuration can silently degrade.
The fix: Use OpenClaw's built-in security audit tool as part of your routine.
# Standard security check
openclaw security audit
# Deep probe that tests live gateway configuration
openclaw security audit --deep
# Auto-fix common issues like file permissions
openclaw security audit --fix
# Machine-readable output for automation
openclaw security audit --json
What the audit checks:
- Inbound access policies (DM and group allowlists)
- Tool blast radius (elevated tools combined with open rooms)
- Network exposure (bind address, authentication, Tailscale configuration)
- Browser control exposure (remote nodes, relay ports)
- Filesystem permissions and symlink attacks
- Plugin safety and version pinning
- Policy drift (sandbox configuration vs. runtime mode mismatch)
Key recommendations:
- Run
openclaw security audit --deepafter every configuration change - Include the audit in your CI/CD pipeline or scheduled maintenance tasks
- Use the
--jsonoutput to feed results into your compliance monitoring tools - Review audit warnings for any
dangerously*flags in your configuration, these are explicit security overrides that should be justified and documented
7. Align with Compliance Frameworks
The problem: AI agents are privileged service accounts that access email, APIs, cloud services, and internal resources. Most organizations have not incorporated them into their access control policies, asset inventories, or risk assessments. Auditors are starting to ask about them.
The fix: Treat OpenClaw deployments as in-scope assets for your compliance program.
For SOC 2:
- Document all AI agent deployments as part of your system description (CC6.1)
- Apply access controls to agent credentials and API tokens
- Maintain audit logs of agent actions and data access patterns
- Include agent compromise in your incident response procedures
For ISO 27001:
- Add AI agents to your asset inventory and classify them by sensitivity (Annex A.5.9)
- Apply access control policies to agent configurations and credentials
- Include agents in your change management process, configuration changes should go through approval
- Perform risk assessments specific to AI agent deployments (Risk Assessment Guide)
Key recommendations:
- Maintain an inventory of every OpenClaw instance running in your environment, including version, configuration, and installed skills
- Assign ownership for each deployment, someone should be accountable for its security posture
- Define clear escalation paths for suspected agent credential theft
- Map the blast radius for each agent: which systems and data can it access?
- Include AI agent compromise scenarios in your next tabletop exercise
The Hardened Baseline: A Starting Point
If you are setting up OpenClaw for the first time, or want to reset an existing deployment to a secure default, here is a complete hardened configuration:
{
gateway: {
mode: "local",
bind: "loopback",
auth: { mode: "token", token: "replace-with-long-random-token" }
},
session: { dmScope: "per-channel-peer" },
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 }
},
channels: {
whatsapp: {
dmPolicy: "pairing",
groups: { "*": { requireMention: true } }
}
},
browser: {
ssrfPolicy: {
dangerouslyAllowPrivateNetwork: false
}
},
logging: {
redactSensitive: "tools"
},
discovery: {
mdns: { mode: "off" }
}
}
Start here, then selectively enable features as your use case requires. Every permission you add should be deliberate, documented, and reviewed.
Conclusion
OpenClaw is a genuinely useful tool, but its default configuration was designed for quick setup, not production security. The incidents of early 2026 proved that threat actors are already targeting AI agents as high-value targets. Gateway tokens, API keys, behavioral guidelines, and session data are all worth stealing.
The best practices in this guide are not theoretical. They map directly to the attack vectors that have already been exploited in the wild: exposed network bindings, plaintext credential storage, malicious marketplace skills, and unchecked agent permissions.
Securing OpenClaw is not fundamentally different from securing any other privileged service in your infrastructure. It just requires recognizing that your AI agent deserves the same rigor you apply to your servers, databases, and CI/CD pipelines.
Need help integrating AI agent security into your compliance program? Bastion helps SaaS companies build security programs that account for emerging threats, including AI agent deployments. Get started today.
Frequently Asked Questions
OpenClaw can be used securely, but not with its default settings. The defaults prioritize ease of setup over security, which led to over 135,000 exposed instances in early 2026. By applying the hardening steps in this guide, binding to localhost, enabling authentication, restricting tool access, and vetting skills, you can significantly reduce your risk.
Network binding. Change gateway.bind from the default (which listens on all interfaces) to "loopback" (localhost only). This single change would have prevented the majority of the 135,000+ exposed instances discovered by SecurityScorecard.
Yes. Security audits found that 820+ out of 10,700 skills on ClawHub were malicious, and 36% contained detectable prompt injection. Always review skill source code before installation, use explicit allowlists, and pin exact versions.
AI agents with access to sensitive systems are effectively privileged service accounts. Auditors expect you to inventory them, apply access controls to their credentials, maintain audit logs of their actions, and include them in your incident response plans. Failing to do so creates gaps in your compliance posture.
Run openclaw security audit --deep after every configuration change and at least monthly as part of routine maintenance. Use the --json flag to integrate results into your compliance monitoring pipeline.
Yes, and it is recommended. OpenClaw supports Docker-based sandboxing with configurable workspace access. Set sandbox.mode to "all" and workspaceAccess to "ro" (read-only) for the strongest isolation. Avoid using docker.network: "host" as it breaks container isolation.
Sources
- OpenClaw Security Documentation
- SecurityScorecard: How Exposed OpenClaw Deployments Turn Agentic AI Into an Attack Surface
- Hudson Rock: Infostealer Infection Targeting OpenClaw Configurations
- DataCamp: OpenClaw Security Best Practices
- Auth0: Securing OpenClaw Developer Guide
- NVD: CVE-2026-25253
- CrowdStrike: What Security Teams Need to Know About OpenClaw
Share this article
Related Articles
OpenClaw Inbox Wipe: 7 AI Agent Security Lessons Every Startup Needs to Learn
An AI email tool deleted Meta's AI Alignment director's entire inbox and ignored stop commands. Here's what startups can learn about AI agent security, kill switches, and compliance controls.
OpenClaw Infostealer Attack: What the First AI Agent Identity Theft Means for Your Security
Infostealer malware stole OpenClaw AI agent configs, gateway tokens, and behavioral guidelines. With 135,000+ exposed instances and 1,184 malicious skills, here's what security teams need to know.
LiteLLM PyPI Supply Chain Attack: What Happened and How to Protect Your Organization
On March 24, 2026, attackers compromised the popular LiteLLM Python package on PyPI, injecting malware that harvested credentials, exfiltrated secrets, and attempted to backdoor Kubernetes clusters. Here's what happened, why it matters, and what your team should do now.
Learn More About Compliance
Explore our guides for deeper insights into compliance frameworks.
ISO 27005: Information Security Risk Management Guide
ISO 27005 provides comprehensive guidance for managing information security risks within an ISO 27001 management system. This standard helps organizations implement the risk assessment and treatment requirements of ISO 27001 with a structured, repeatable methodology.
NIS 2 Supply Chain Security Requirements
Supply chain security is one of the most significant additions in NIS 2 compared to the original directive. Article 21(2)(d) specifically mandates that organizations address cybersecurity risks in their relationships with suppliers and service providers. This reflects the growing recognition that an organization's security is only as strong as its weakest link in the supply chain.
NIS 2 Risk Assessment: How to Evaluate Cybersecurity Risks
Risk assessment is the foundation of NIS 2 compliance. Article 21 requires organizations to take a risk-based approach to cybersecurity, meaning all security measures must be proportionate to the risks identified. A structured risk assessment process helps you identify threats, evaluate vulnerabilities, and prioritize your cybersecurity investments effectively.
Other platforms check the box
We secure the box
Get in touch and learn why hundreds of companies trust Bastion to manage their security and fast-track their compliance.
Get Started