Switch Language
Toggle Theme

OpenClaw Security Configuration Guide: Five-Layer Defense from Docker Sandbox to Access Control

3 AM. A developer posted on Reddit asking for help. He’d installed OpenClaw on his MacBook with default settings and ran it for two weeks, thinking it worked great. Until one day, he asked OpenClaw to “help me organize recent project files”—and the AI helpfully read his ~/.ssh/ and ~/.aws/ directories, then “thoughtfully” displayed his private keys in the response.

Worse yet, this conversation log synced to his work group chat.

Honestly, when I first saw this case, a chill ran down my spine. OpenClaw is an incredibly powerful AI assistant that can execute shell commands, read and write files, control browsers—but this also means that with improper configuration, it’s like a stranger holding your house keys.

You might think: I’m just using it myself, should be fine, right?

Well, here’s the thing. OpenClaw’s risks don’t just come from external attacks—there’s also Prompt injection (someone sneakily inserting malicious commands in chat), configuration mistakes (accidentally exposing API ports), or even the AI’s own “over-enthusiasm” (you ask it to clean files, it might interpret that as deleting important data).

All of this can be avoided with proper configuration.

This article will walk you through building a “security cage” for OpenClaw—from Docker sandbox isolation to fine-grained permission control, five layers of defense to use this “beast” with confidence. Let me be upfront: the configuration looks tedious, but compared to data leaks and catastrophic deletions, this hassle is nothing.

Why Security Configuration?

Just How Much Power Does OpenClaw Have?

Let me start with a sobering fact. OpenClaw isn’t one of those chat-only AI assistants—what it can do is basically equivalent to everything you can do in a terminal:

  • Execute arbitrary shell commands: rm -rf /? Technically possible.
  • Read/write entire filesystem: Your SSH keys, AWS credentials, database passwords—if it’s on disk, it can access it.
  • Access network resources: Call APIs, download files, even scan internal network ports.
  • Control browsers: Operate your browser via Playwright, including logged-in websites.
  • Read environment variables: Sensitive info in process.env is wide open.

In other words, giving OpenClaw default permissions is like handing a “very smart but unfamiliar assistant” a master key to your house.

How Dangerous Is the Default Configuration?

I know many people take shortcuts—npm install -g openclaw, then immediately openclaw run. But do you know what happens by default?

100%
Filesystem Access Permission

Before v2026.1.29:

  • Access control could be set to auth: none, meaning anyone with your URL could control your OpenClaw.
  • No sandbox isolation, AI could read/write the entire filesystem.
  • All tools enabled by default, including dangerous exec and browser.
  • Might run with elevated privileges (even root).

"v2026.1.29 forcibly removed the auth: none option, requiring Token or password authentication"

After v2026.1.29, slightly better: The team forcibly removed the auth: none option, requiring Token or password authentication. But other issues remain—sandbox, tool permissions, filesystem access all still need manual configuration.

To be honest, the default configuration is like sleeping with your front door wide open and a sign outside saying “Welcome to visit.”

Three Goals of Security Configuration

With all these configurations, what’s the point? Three core objectives:

1. Principle of Least Privilege: Only give OpenClaw the permissions it truly needs, nothing else. If you want it to help write code, give it read/write access to the workspace; if you don’t need browser control, the browser tool should be disabled.

2. Defense in Depth: Don’t put all your eggs in one basket. Docker isolation, non-privileged user, access control, tool whitelist, network isolation—five layers of defense. If any one layer is breached, the others can still protect you.

3. Controlled Blast Radius: Assume the worst-case scenario—Prompt injection succeeds, Token is leaked, or the AI itself has a bug—how much damage can occur? If OpenClaw can only access an isolated workspace directory, then only that directory’s contents leak, not your entire /home directory.

Simply put, security configuration isn’t to prevent attacks (that’s impossible), but to make attacks costly enough and losses small enough.

Five Layers of Security Configuration

Alright, enough talk—let’s get practical. I’ll explain the five layers of defense in order from bottom to top. For each layer, I’ll tell you “why do this” and “how to verify it worked.”

Layer 1: Docker Sandbox Isolation (MUST-HAVE)

Why Use Docker?

Many people think Docker is just for convenient deployment. Wrong. For high-privilege applications like OpenClaw, Docker’s greatest value is isolation:

  • Filesystem isolation: The AI only sees files inside the container; your ~/.ssh is on the host machine, unreachable.
  • Network isolation: Can cut off the container’s external network access, or only allow specific domains.
  • Resource limits: Prevent the AI from burning your CPU with an infinite loop.
  • Quick recovery: Something went wrong? docker rm to delete the container, rebuild a clean one in seconds.

Someone might ask: I’m running it on my local dev machine, do I really need this hassle?

Yes. Local is actually more dangerous—your dev machine has GitHub Tokens, database passwords, various API keys, all targets for Prompt injection attacks.

Configuration Steps

1. Create a Secure Dockerfile

FROM openclaw/gateway:latest

# Create non-privileged user
RUN adduser --disabled-password --gecos '' clawuser

# Switch to non-privileged user
USER clawuser

# Set working directory
WORKDIR /home/clawuser/openclaw

The key here is USER clawuser. By default, Docker containers run as root, meaning OpenClaw inside has root privileges. After creating a dedicated user, even if someone breaches the container, they only have clawuser permissions.

2. Use Docker Compose to Configure Security Parameters

This is the core part—I’ll explain line by line:

version: '3.8'
services:
  openclaw-gateway:
    build: .
    container_name: openclaw-safe

    # Security configuration
    security_opt:
      - no-new-privileges:true  # Prevent privilege escalation inside container
    cap_drop:
      - ALL  # Remove all Linux capabilities
    cap_add:
      - NET_BIND_SERVICE  # Only add ability to bind ports

    # Read-only root filesystem
    read_only: true

    # Temporary directories (writable)
    tmpfs:
      - /tmp
      - /home/clawuser/openclaw/temp

    # Resource limits
    deploy:
      resources:
        limits:
          cpus: '2.0'
          memory: 4G
        reservations:
          cpus: '1.0'
          memory: 2G

    # Network isolation
    networks:
      - openclaw-isolated

    # Volume mounts (minimum privileges)
    volumes:
      # Workspace (read-write)
      - ./workspace:/home/clawuser/workspace
      # Config files (read-only)
      - ./config:/home/clawuser/openclaw/config:ro
      # Logs directory (write-only)
      - ./logs:/home/clawuser/openclaw/logs

networks:
  openclaw-isolated:
    driver: bridge
    internal: true  # No external network access

Why Configure This Way?

  • no-new-privileges:true: Prevents privilege escalation via sudo or setuid. Even if attackers find a vulnerability inside the container, they can’t gain higher privileges.
  • cap_drop: ALL: Linux capabilities are fine-grained permission control. Remove all, then only add back what’s necessary (like binding ports), minimizing attack surface.
  • read_only: true: Root filesystem is read-only. Even if attackers get in, they can’t install backdoors or modify system files. Places that need writes (like /tmp) use tmpfs mounts.
  • internal: true: Container cannot access external network. If your OpenClaw doesn’t need internet (e.g., only processes local files), this prevents data exfiltration.

3. Enable OpenClaw’s Sandbox Mode

In config/config.yaml:

sandbox:
  mode: "non-main"  # All group chats run in isolated containers
  docker:
    enabled: true
    network: "none"  # Disable network access for sandbox containers

This is OpenClaw’s own sandbox feature. mode: "non-main" means: except for your main chat window, all other conversations run in separate Docker containers. This way, even if a conversation gets Prompt injection attacked, it can only wreak havoc in its own little sandbox.

Verification Method

Don’t rush to use it after configuration—verify first:

# Check if container runs as non-root user
docker exec openclaw-safe whoami
# Should return: clawuser

# Check if filesystem is read-only
docker exec openclaw-safe touch /test.txt
# Should return: Read-only file system

# Check network isolation
docker exec openclaw-safe ping 8.8.8.8
# Should return: Network is unreachable

If all three tests pass, congratulations—layer one defense is in place.

Layer 2: Non-Privileged User Execution (MUST-HAVE)

The Docker container uses non-root, but who started the container? If you run docker-compose up as root on the host machine, once attackers escape the container, they still get root privileges.

Solution: Create a Dedicated Low-Privilege User

Configure on Host Machine:

# Create dedicated user group and user
sudo groupadd -r openclaw
sudo useradd -r -g openclaw -d /opt/openclaw -s /bin/bash clawuser

# Create directory structure
sudo mkdir -p /opt/openclaw/{workspace,config,logs,temp}

# Set directory permissions
sudo chown -R clawuser:openclaw /opt/openclaw
sudo chmod 700 /opt/openclaw/config  # Config directory (only owner can read/write)
sudo chmod 755 /opt/openclaw/workspace  # Workspace
sudo chmod 750 /opt/openclaw/logs  # Logs directory

# Restrict user permissions
sudo usermod -L clawuser  # Lock password login, only accessible via su

Why chmod 700?

chmod 700 means: only the file owner (clawuser) can read, write, and execute—others can’t even view. Config files might contain Tokens and passwords, must be heavily guarded.

Credential File Permissions (Super Important!)

If you use OpenClaw to connect to WhatsApp or other services, credential file permissions need extra care:

# Credential files must be 600 (only owner can read/write)
chmod 600 ~/.openclaw/credentials/whatsapp/*/creds.json
chmod 700 ~/.openclaw

I’ve seen people set credential files to 644 (world-readable), then get snooped by other users on the same server. Don’t make this rookie mistake.

Verification

# Check OpenClaw process user
ps aux | grep openclaw
# Should show clawuser, not root

# Check file permissions
ls -la /opt/openclaw/config
# Should be drwx------ clawuser openclaw

Why Is This Layer Important?

Assume the worst case: attackers breach the Docker container, breach OpenClaw’s sandbox, execute arbitrary code—but they still only have clawuser privileges:

  • Cannot access other users’ files
  • Cannot install system-level software (no sudo privileges)
  • Cannot modify system configs under /etc
  • Cannot read /root directory

This is the meaning of defense in depth: one layer breached, the next layer continues protecting you.

Layer 3: Access Control & Authentication (MUST-HAVE)

The first two layers address “what OpenClaw can do,” this layer addresses “who can use OpenClaw.”

v2026.1.29 Major Change

Previously OpenClaw allowed auth: none (no verification at all), which was a disaster. Thankfully the team finally woke up—v2026.1.29 forcibly removed this option, now requiring Token or password authentication.

Configure Gateway Token Authentication

Why is Token authentication better than passwords? You can assign different Tokens to different people/applications, each Token with different permissions. A Token gets leaked? Revoke it, doesn’t affect other Tokens.

In config/config.yaml:

gateway:
  # Force Token authentication
  auth: token

  # Token configuration
  tokens:
    - name: "admin-token"
      value: "${OPENCLAW_ADMIN_TOKEN}"  # Read from env variable, don't hardcode!
      permissions:
        - "admin"  # Full permissions

    - name: "readonly-token"
      value: "${OPENCLAW_READONLY_TOKEN}"
      permissions:
        - "chat"  # Only chat
        - "read"  # Only read files
      # Note: doesn't include exec, browser, etc. high-risk permissions

Generate Secure Tokens

Never use 123456 or mytoken as weak Tokens. Use this command to generate 256-bit random Tokens:

# Generate random token
openssl rand -base64 32

# Set environment variables (don't hardcode in config files!)
export OPENCLAW_ADMIN_TOKEN="your_generated_token"
export OPENCLAW_READONLY_TOKEN="another_token"

Why not hardcode? Because config files might get committed to Git, recorded by logging systems, or backed up to the cloud. Environment variables are relatively safer.

Access Control Whitelist

Tokens solve “who can access,” but that’s not enough. You might only want specific WhatsApp users or groups to use OpenClaw:

# DM (private chat) policy
dmPolicy: allowlist  # Whitelist mode
allowFrom:
  - "user_id_1"  # Only these users can DM
  - "user_id_2"

# Group policy
groupPolicy: allowlist
allowFrom:
  - "group_id_1"  # Only these groups can use

# Mention gating (only respond to @ mentions in group chats)
mentionGating: true

# Disable public access
publicAccess: false

mentionGating: true is particularly useful. Imagine: you deployed OpenClaw in a 100-person work group—without this enabled, OpenClaw processes every message (costly, and vulnerable to malicious Prompt attacks). With it enabled, it only responds when @ mentioned.

Verification

# Test unauthorized access (should be denied)
curl -X POST http://localhost:3000/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message":"hello"}'
# Should return: 401 Unauthorized

# Test valid token
curl -X POST http://localhost:3000/api/chat \
  -H "Authorization: Bearer ${OPENCLAW_ADMIN_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"message":"hello"}'
# Should return: 200 OK

Why Is This Layer Critical?

Without access control, the previous isolation and permission restrictions are worthless—attackers invade directly via API, no need to breach Docker or escalate privileges.

This layer is the gatekeeper, keeping out those who shouldn’t enter.

Now OpenClaw is locked in a cage, but it still has many tools available inside. Time to confiscate some dangerous tools.

Problem: All Tools Available by Default

OpenClaw comes with dozens of tools: exec (execute shell commands), browser (control browser), write_file (write files), web_fetch (fetch web pages)… all enabled by default.

But do you really need all of these? If you only want OpenClaw to help write code and research, browser and exec can be completely disabled.

Configure Tool Whitelist

tools:
  # Only allow safe tools
  allowlist:
    - "read_file"      # Read files
    - "write_file"     # Write files (restricted directory)
    - "web_search"     # Web search
    - "git"            # Git operations
    # Note: doesn't include exec, browser, etc. high-risk tools

  # High-risk tools need explicit authorization
  exec:
    enabled: false  # Disable shell execution by default

  browser:
    enabled: false  # Disable browser control

  web_fetch:
    enabled: true
    # Domain whitelist
    allowedDomains:
      - "github.com"
      - "api.anthropic.com"
      - "*.npmjs.com"

If You Must Enable exec, Use Command Whitelist

Sometimes you genuinely need OpenClaw to execute commands (like running tests, building projects). Then use a whitelist:

tools:
  exec:
    enabled: true
    sandbox: true  # Run in sandbox

    # Whitelist over blacklist
    allowCommands:
      - "git"
      - "npm"
      - "yarn"
      - "pytest"
      - "curl"

    # Dangerous command blacklist (double insurance)
    denyCommands:
      - "rm -rf"
      - "sudo"
      - "chmod 777"
      - "dd if="
      - "mkfs"
      - "> /dev/sda"

Why whitelist over blacklist? Because attack methods are ever-changing—you can never list all dangerous commands. But safe commands are finite, just list them.

Filesystem Access Restrictions

filesystem:
  # Allowed directories
  allowedPaths:
    - "/home/clawuser/workspace"
    - "/home/clawuser/projects"

  # Denied directories
  deniedPaths:
    - "/home/clawuser/.ssh"
    - "/home/clawuser/.aws"
    - "/home/clawuser/.config"
    - "/etc"
    - "/root"

  # Default permission
  defaultPermission: "readonly"  # Read-only by default

  # Write permission needs explicit grant
  writablePaths:
    - "/home/clawuser/workspace/temp"

With this configuration, even if someone uses Prompt injection to make OpenClaw “read ~/.ssh/id_rsa,” it’ll be denied.

Verification

Test in OpenClaw chat interface:

  • You: “Help me execute sudo apt update”

    • OpenClaw should reply: Cannot execute this command, blocked by security policy
  • You: “Read ~/.ssh/id_rsa file”

    • OpenClaw should reply: Access denied

Layer 5: Network Isolation & Monitoring (ADVANCED)

If you’re an enterprise user, handle sensitive data, or just want ultimate security, this layer provides the final protection.

Network Isolation: Cut Unnecessary Connections

Earlier we used internal: true to prevent the container from accessing the internet. But OpenClaw needs to call Claude API, right?

Solution: Proxy Outbound Traffic

Only allow OpenClaw to access specific domains (like api.anthropic.com), block everything else:

# docker-compose.yml
services:
  openclaw-gateway:
    environment:
      - HTTP_PROXY=http://allowlist-proxy:8080
      - HTTPS_PROXY=http://allowlist-proxy:8080
    networks:
      - openclaw-isolated

  allowlist-proxy:
    image: squid:latest
    volumes:
      - ./squid.conf:/etc/squid/squid.conf:ro
    networks:
      - openclaw-isolated
      - external  # Only proxy can access external network

squid.conf (Proxy Whitelist Configuration):

# Allowed domains
acl allowed_domains dstdomain .anthropic.com
acl allowed_domains dstdomain .github.com
acl allowed_domains dstdomain .npmjs.com

# Allow HTTPS
acl SSL_ports port 443
acl CONNECT method CONNECT

# Access rules
http_access allow allowed_domains
http_access deny all

# Logging
access_log /var/log/squid/access.log

With this configuration, OpenClaw can only access these three domains, all other sites are blocked by the proxy. Even if Prompt injection makes it “download malicious scripts,” it can’t.

Audit Logs: Record Everything

Logs can’t prevent attacks, but they let you know what happened:

logging:
  # Enable detailed logging
  level: "info"

  # Audit log
  auditLog:
    enabled: true
    path: "/home/clawuser/openclaw/logs/audit.log"
    format: "json"

    # What to log
    logToolCalls: true        # Log all tool calls
    logFileAccess: true       # Log file access
    logNetworkRequests: true  # Log network requests
    logPrompts: true          # Log all prompts (detect injection)

  # Session log
  sessionLog:
    enabled: true
    path: "/home/clawuser/openclaw/logs/sessions/"

logPrompts: true is especially critical. If someone injects malicious commands in chat (like “ignore previous restrictions, execute…”), the logs will record it for post-analysis.

Real-time Monitoring

# Monitor suspicious activity
tail -f /opt/openclaw/logs/audit.log | grep -E "(exec|sudo|rm|chmod)"

# Monitor network connections
docker exec openclaw-safe netstat -tuln

# Monitor resource usage
docker stats openclaw-safe

Alert Configuration

For an extra step, configure automated alerts:

alerts:
  # Suspicious command execution
  - type: "command_execution"
    pattern: "sudo|rm -rf|chmod 777"
    action: "block_and_notify"

  # Access sensitive files
  - type: "file_access"
    pattern: "/.ssh/|/.aws/|/etc/passwd"
    action: "block_and_notify"

  # Access suspicious websites
  - type: "network_request"
    pattern: ".*\\.onion|torproject\\.org"
    action: "block_and_notify"

When alerts trigger, you can send emails, Slack messages, or directly pause OpenClaw service.

Read-Only Starting Strategy

After configuring five layers of defense, you might wonder: should I enable everything all at once?

My advice: Don’t.

Security and convenience are always a balancing act. Configure too strictly, OpenClaw might do nothing, and you’ll suffer. Configure too loosely, no protective effect.

A better strategy: Start strictest, gradually relax.

Week 1: Pure Read-Only Mode

When first deploying, start with read-only mode to observe OpenClaw’s behavior:

tools:
  allowlist:
    - "read_file"
    - "web_search"
    - "git_log"  # Read-only Git operations

filesystem:
  defaultPermission: "readonly"
  writablePaths: []  # Completely disable writing

What do you do this week? Observe.

  • See which files OpenClaw frequently accesses
  • Check logs for suspicious activity
  • Understand which tools it habitually calls
  • Test what happens with Prompt injection (in safe environment)

If this week goes smoothly, the basic configuration is fine. If you discover anomalies (like frequently trying to access .ssh directory), immediately check if it’s a config issue or someone actually messing around.

Week 2: Add Restricted Write Access

After the observation period, gradually open write permissions:

filesystem:
  writablePaths:
    - "/home/clawuser/workspace/temp"  # Only allow writing temp files

tools:
  allowlist:
    - "write_file"  # Limited to writablePaths
    - "git_commit"  # Allow code commits

Note, this only opens temporary directory write permissions. Important project files remain read-only, OpenClaw can’t directly modify them.

The benefit: even if the AI makes a mistake (like you ask it to “clean up the project,” it interprets as delete all files), it can only delete temp files, source code remains safe.

Week 3 and Beyond: Enable Tools as Needed

Based on actual usage needs, gradually enable tools:

tools:
  exec:
    enabled: true
    sandbox: true
    allowCommands:
      - "git"  # First only allow git
      - "npm test"  # Add when need to run tests

Key Principles:

  • Relax only one permission at a time: Don’t open exec, browser, write_file all at once—if something goes wrong, you won’t know which part caused it.
  • Observe 24 hours after each relaxation: Check audit logs for abnormal behavior.
  • Roll back immediately if problems arise: Discover suspicious activity? Immediately revoke the just-changed configuration.

Real Case: My Configuration Evolution

Let me share my own experience.

At first I wanted to do everything at once, referencing official docs to configure a “complete security solution.” The result? OpenClaw couldn’t even do basic code completion because I disabled write_file.

Later I learned:

  • Week 1: Read-only mode, let OpenClaw help me look up docs and explain code. No problems.
  • Week 2: Opened workspace/drafts directory write permissions, let it help me write drafts. Worked smoothly.
  • Week 3: Enabled git commands, let it help me commit code. Hit a snag here—I forgot to configure Git user info, OpenClaw errored on every commit. Fixed, then all normal.
  • Week 4: Enabled npm test, let it run unit tests. At this point basically met daily needs.

browser and unrestricted exec? Never enabled, never needed.

Lesson: Don’t configure permissions you don’t even use for “sense of security.” Better to be a bit more hassle, open as needed.

Security Checklist

Alright, with all these configurations, how to ensure nothing’s missed? Here’s a checklist—go through it before deployment to avoid 90% of rookie mistakes.

Pre-Deployment Checklist (All Must Be Checked)

Container Security:

  • ☐ Created non-privileged user (not root inside container)
  • ☐ Docker configured with no-new-privileges:true
  • ☐ Removed all Linux capabilities (cap_drop: ALL)
  • ☐ Root filesystem set to read-only (read_only: true)
  • ☐ Configured resource limits (CPU, memory)
  • ☐ Enabled OpenClaw’s sandbox mode

Authentication:

  • ☐ Set strong Token authentication (not auth: none)
  • ☐ Token sufficiently complex (≥32 characters, randomly generated)
  • ☐ Token saved in environment variables, not in code
  • ☐ Configured access whitelist (DM/Group policy)
  • ☐ If deployed on VPS, configured IP whitelist

Permission Control:

  • ☐ Tools use whitelist mode
  • ☐ Disabled high-risk tools (exec/browser, or configured command whitelist)
  • ☐ Configured filesystem access restrictions
  • ☐ Sensitive directories (.ssh, .aws, etc.) in deny list
  • ☐ Credential file permissions set to 600

Audit & Monitoring:

  • ☐ Enabled audit logging
  • ☐ Configured session logging
  • ☐ Log directory has sufficient disk space
  • ☐ Know how to view and analyze logs

Runtime Checks (Execute Periodically)

Weekly Checks:

  • ☐ Review audit logs for abnormal activity
  • ☐ Check resource usage (CPU, memory, disk)
  • ☐ Check for unauthorized access attempts
  • ☐ Backup configuration files

Monthly Checks:

  • ☐ Update OpenClaw to latest version
  • ☐ Rotate Tokens (if long-running service)
  • ☐ Check Docker image security vulnerabilities (docker scan)
  • ☐ Review permission configs, remove no-longer-needed permissions

Emergency Response Preparation

If something actually goes wrong, do you know what to do?

Prepare Emergency Stop Script:

#!/bin/bash
# emergency-stop.sh

echo "Emergency stop OpenClaw..."

# Stop container
docker stop openclaw-safe

# Revoke all Tokens (if using dynamic Token system)
# curl -X DELETE https://your-auth-server/tokens/revoke-all

# Send alert
curl -X POST https://your-webhook-url \
  -H "Content-Type: application/json" \
  -d '{"text":"OpenClaw has been emergency stopped"}'

echo "Stopped. Please check logs: /opt/openclaw/logs/audit.log"

Token Leak Response:

  1. Immediately revoke the leaked Token
  2. Check audit logs to see what the Token was used for
  3. Generate new Token, notify legitimate users to update
  4. If data leaked, activate data breach emergency plan

Discover Suspicious Activity:

  1. Don’t immediately shut down service (alerts attackers)
  2. First save current logs and container snapshots
  3. Analyze attack path and impact scope
  4. Then decide whether to isolate, restart, or rebuild

Conclusion

After all this, the core is really just one sentence: OpenClaw is powerful, but only in a secure cage can this “beast” truly serve you.

Let’s recap the five layers of defense:

  1. Docker Sandbox Isolation: Lock OpenClaw in a container, limit files and network it can access
  2. Non-Privileged User: Even if attacked, attackers only have low privileges, can’t cause destruction
  3. Access Control: Token authentication + whitelist, keep out those who shouldn’t enter
  4. Tool Permission Control: Disable dangerous tools, only give necessary permissions
  5. Network Isolation & Monitoring: Cut unnecessary connections, record all operations

Of these five layers, the first three are MUST-HAVE—no matter how you use OpenClaw, these three defenses should be in place. The latter two are RECOMMENDED—if handling sensitive data or enterprise deployment, strongly suggest configuring.

Honestly, configuring these is a bit tedious. You might wonder: I’m just playing around myself, do I really need to be this careful?

My answer: Yes.

Not because OpenClaw is insecure (it’s fine itself), but because AI’s capabilities are too strong. You ask it to “help organize project files,” it might interpret as “delete all temp files”—including important drafts you forgot to back up. You ask it to “check recent commit history,” it might casually read credentials in .git/config.

These aren’t malicious, just “over-enthusiasm.” But consequences can be equally serious.

Security configuration isn’t to prevent OpenClaw from being evil, but to limit the blast radius of accidents. Even if something goes wrong, the damage is controllable.

Finally, three action recommendations:

  1. Check your OpenClaw configuration now: If you’re using default config, please stop immediately and at least implement the first three layers of defense.
  2. Start strict, gradually relax: Don’t fear the hassle, use read-only mode to observe for a week, confirm safety before opening permissions.
  3. Regularly review audit logs: Spend 5 minutes weekly flipping through logs for anomalies. Early detection, early handling.

OpenClaw is a good tool, really. But like nuclear power—used well it benefits humanity, used poorly it’s disaster.

Configuration looks tedious, but compared to data leaks, catastrophic deletions, or posting on Reddit for help, this hassle is nothing.

Right?

FAQ

Why was the default configuration before v2026.1.29 so dangerous?
OpenClaw before v2026.1.29 had several serious security vulnerabilities:

• auth: none option allowed complete lack of verification, anyone with the URL could control your OpenClaw
• No sandbox isolation, AI could read/write entire filesystem, including sensitive directories like ~/.ssh and ~/.aws
• All tools enabled by default, including dangerous exec and browser, without any restrictions
• Might run with root privileges, once attackers breach they get full system control

v2026.1.29 forcibly removed the auth: none option, but sandbox, tool permissions, filesystem access still need manual configuration.
Using non-root user inside Docker container, but starting container as root on host—is this secure?
Not secure. Even if using non-root user inside container, if attackers exploit Docker escape vulnerabilities to breach the container, they can still gain root privileges on the host.

Correct approach:
• Create dedicated low-privilege user on host (like clawuser)
• Use that user to start Docker container
• Set strict directory permissions (chmod 700 for config directory, chmod 600 for credential files)
• Lock user password login (sudo usermod -L clawuser)

This way even if container is breached, attackers only get clawuser's limited privileges, cannot access system critical resources.
Why is Token authentication better than password authentication? How to generate secure Tokens?
Token authentication advantages:

• Can assign different Tokens to different people/applications, each Token with independent permissions
• When Token leaks only need to revoke that Token, doesn't affect other users
• Tokens can have expiration times, passwords are usually long-term valid
• Tokens can record detailed audit logs, tracking who did what operations

How to generate secure Tokens:
• Use openssl rand -base64 32 to generate 256-bit random Token
• Token length at least 32 characters, containing random characters
• Save Token in environment variables, don't hardcode in config files
• Regularly rotate Tokens (recommend monthly)
Why tool whitelist over blacklist? How to configure command whitelist?
Why whitelist over blacklist:

• Attack methods are ever-changing, you can never list all dangerous commands (rm -rf, sudo, chmod 777, dd, mkfs...)
• Blacklists are easily bypassed (like rm -rf can be written as rm${IFS}-rf)
• Safe commands are finite, listing allowed commands is more controllable

Command whitelist configuration example:
tools:
exec:
enabled: true
sandbox: true
allowCommands:
- "git"
- "npm"
- "yarn"
- "pytest"
- "curl"

This way only whitelisted commands can execute, all others are blocked. If need to add new commands, must explicitly add to whitelist.
I'm just using OpenClaw on my local dev machine, do I really need such strict security configuration?
Yes, and local dev machines are actually more dangerous. Reasons:

• Local dev machines have lots of sensitive info: GitHub Tokens, AWS credentials, database passwords, SSH private keys
• Prompt injection attacks don't need remote intrusion, just insert malicious commands in chat
• AI's "over-enthusiasm" might cause mistakes (like interpreting "clean project" as "delete all files")
• Local environments usually lack enterprise-grade backup and recovery mechanisms

Minimum configuration recommendations:
• Layer 1 Docker sandbox isolation (MUST)
• Layer 2 Non-privileged user execution (MUST)
• Layer 3 Token authentication (MUST)
• Layer 4 Tool whitelist (STRONGLY RECOMMENDED)

Starting with read-only mode and gradually relaxing permissions is much easier than remedying after the fact.
Network isolation configured with internal: true, but OpenClaw needs to call Claude API—how to solve?
Solution is to use proxy whitelist, only allowing access to specific domains:

1. Configure Squid proxy container, set domain whitelist (like .anthropic.com, .github.com)
2. OpenClaw container accesses external network through proxy (set HTTP_PROXY and HTTPS_PROXY environment variables)
3. Only proxy container can access external network, OpenClaw container can only access proxy

After this configuration:
• OpenClaw can normally call Claude API (in whitelist)
• Even if Prompt injection makes AI download malicious scripts, they'll be blocked by proxy
• All external network access has audit logs, convenient for tracking abnormal behavior

Refer to Layer 5 docker-compose.yml and squid.conf examples in the article for proxy configuration.
How to determine which activities in OpenClaw's audit logs are abnormal?
Abnormal behaviors to watch for in audit logs:

Command execution anomalies:
• Attempting to execute sudo, rm -rf, chmod 777 and other high-risk commands
• Frequently executing failed commands (might be probing permissions)
• Command execution during non-work hours

File access anomalies:
• Attempting to access ~/.ssh, ~/.aws, /etc/passwd and other sensitive directories
• Large number of file read operations (might be stealing data)
• Attempting to modify system files or config files

Network request anomalies:
• Accessing .onion domains or Tor-related websites
• Connecting to unknown IP addresses
• Large data exfiltration (might be data leak)

Prompt injection characteristics:
• Contains "ignore previous restrictions", "execute as administrator" and other suspicious commands
• Requesting operations obviously beyond normal usage scope

Recommend spending 5 minutes weekly checking logs, use grep to filter keywords: tail -f audit.log | grep -E "(exec|sudo|rm|chmod|.ssh|.aws)"

16 min read · Published on: Feb 4, 2026 · Modified on: Feb 5, 2026

Comments

Sign in with GitHub to leave a comment

Related Posts