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:- Token (Recommended)
- Password
- Trusted Proxy
- None (Development Only)
Token authentication — Secure, long-lived shared secret.Token source priority:
OPENCLAW_GATEWAY_TOKENenvironment variablegateway.auth.tokenin config
src/gateway/auth.ts:216Rate Limiting
Automatic protection against brute-force attacks:- Tracks failed auth attempts by client IP
- Automatic lockout after 10 failed attempts
- 5-minute cooldown period
- Loopback (localhost) is exempt by default
DM Pairing and Allowlists
DM Policy Modes
Control who can send direct messages:Pairing Flow
Default behavior (recommended):- Gateway generates a pairing code (e.g.,
ABC123) - User receives: “Pairing required. Code: ABC123”
- Approve with:
openclaw pairing approve discord ABC123 - User is added to allowlist store
Allowlist Configuration
Per-channel allowlists:Multi-User Session Isolation
By default, all DM senders share themain session. Isolate sessions per sender:
src/commands/doctor-security.ts:116-122 for warnings about shared sessions.
Network Security
Gateway Bind Modes
Local-only (most secure):
TLS/SSL Setup
Option 1: Tailscale (Recommended)
Tailscale provides automatic TLS with built-in authentication:src/gateway/auth.ts:153-184:
- Verifies
Tailscale-User-Loginheader - Validates via
tailscale whoislookup - Matches login against IP ownership
Option 2: Reverse Proxy (Nginx)
Option 3: Cloudflare Tunnel
Secrets Management
Credential Storage
OpenClaw stores credentials in:Environment Variables
Avoid committing secrets:Rotating Credentials
Security Auditing
Run Security Audit
- Gateway authentication configuration
- DM policy security
- Channel allowlist completeness
- File permissions on state directory
- Network exposure risks
- Credential storage security
src/cli/security-cli.ts and src/commands/doctor-security.ts.
Doctor Security Checks
src/commands/doctor-security.ts):
- Gateway bound to network without auth
- Open DM policies
- Multi-user sessions sharing
mainscope - 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
Gateway exposed without authentication
Gateway exposed without authentication
Problem: Gateway bound to
0.0.0.0 (LAN) without token/password.Fix:Open DM policy misconfigured
Open DM policy misconfigured
Problem:
dmPolicy: open without allowFrom: ["*"].Fix:Weak or default tokens
Weak or default tokens
Problem: Short or predictable authentication tokens.Fix:
Insecure file permissions
Insecure file permissions
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

