Skip to main content

Security Guide

OpenClaw connects to real messaging platforms and executes code. This guide covers essential security practices for protecting your gateway and preventing unauthorized access.

Security Overview

OpenClaw security model:
  • Gateway authentication — Token or password-based access control
  • DM pairing — Controlled access for direct messages
  • Allowlists — Per-channel sender restrictions
  • Rate limiting — Automatic protection against brute-force attacks
  • TLS/SSL — Encrypted connections (Tailscale, reverse proxy)
  • Secrets management — Secure credential storage

Gateway Authentication

Authentication Modes

The gateway supports four authentication modes:

Rate Limiting

Automatic protection against brute-force attacks:
Features:
  • Tracks failed auth attempts by client IP
  • Automatic lockout after 10 failed attempts
  • 5-minute cooldown period
  • Loopback (localhost) is exempt by default
Configuration:

DM Pairing and Allowlists

DM Policy Modes

Control who can send direct messages:

Pairing Flow

Default behavior (recommended):
When an unknown user sends a DM:
  1. Gateway generates a pairing code (e.g., ABC123)
  2. User receives: “Pairing required. Code: ABC123”
  3. Approve with: openclaw pairing approve discord ABC123
  4. User is added to allowlist store
Approve a sender:

Allowlist Configuration

Per-channel allowlists:
Open DM policy (dangerous):
dmPolicy: open allows anyone to send DMs. Only use this if you fully understand the risks.

Multi-User Session Isolation

By default, all DM senders share the main session. Isolate sessions per sender:
See src/commands/doctor-security.ts:116-122 for warnings about shared sessions.

Network Security

Gateway Bind Modes

Local-only (most secure):
LAN access (requires strong auth):
Tailscale (recommended for remote access):

TLS/SSL Setup

Tailscale provides automatic TLS with built-in authentication:
Tailscale authentication verification: From src/gateway/auth.ts:153-184:
  • Verifies Tailscale-User-Login header
  • Validates via tailscale whois lookup
  • Matches login against IP ownership

Option 2: Reverse Proxy (Nginx)

Option 3: Cloudflare Tunnel

Secrets Management

Credential Storage

OpenClaw stores credentials in:
File permissions:

Environment Variables

Avoid committing secrets:
Load environment file:

Rotating Credentials

Security Auditing

Run Security Audit

Audit checks:
  • Gateway authentication configuration
  • DM policy security
  • Channel allowlist completeness
  • File permissions on state directory
  • Network exposure risks
  • Credential storage security
From src/cli/security-cli.ts and src/commands/doctor-security.ts.

Doctor Security Checks

Doctor security warnings (from src/commands/doctor-security.ts):
  • Gateway bound to network without auth
  • Open DM policies
  • Multi-user sessions sharing main scope
  • Missing allowlists
  • Weak authentication

Security Checklist

1

Enable strong authentication

2

Use DM pairing

3

Isolate user sessions

4

Restrict network binding

5

Secure credential storage

6

Run security audit

7

Enable rate limiting (default on)

Verify rate limiting is active:
8

Use TLS for remote access

Set up Tailscale or reverse proxy with Let’s Encrypt

Common Security Issues

Problem: Gateway bound to 0.0.0.0 (LAN) without token/password.Fix:
Problem: dmPolicy: open without allowFrom: ["*"].Fix:
Problem: Multiple DM senders sharing the main session.Fix:
Problem: Short or predictable authentication tokens.Fix:
Problem: Config/credentials readable by other users.Fix:

Next Steps

Deployment Guide

Deploy with security best practices

Troubleshooting

Debug authentication and security issues

Multi-Agent Setup

Isolate agents with allowlists

CLI Reference

Security audit command reference