Skip to main content
🎤 Speaking at KubeCon EU 2026 Lessons Learned Orchestrating Multi-Tenant GPUs on OpenShift AI View Session
🎤 Speaking at Red Hat Summit 2026 GPUs take flight: Safety-first multi-tenant Platform Engineering with NVIDIA and OpenShift AI Learn More
AI

Security Hardening for OpenClaw on Azure

Luca Berton 3 min read
#openclaw#security#azure#hardening#https#tailscale#nsg#devops

🛡️ Why Security Matters for AI Gateways

OpenClaw sits between your AI models and your messaging platforms. A compromised gateway means:

  • Unauthorized access to your AI model API keys
  • Ability to impersonate your bot on connected channels
  • Access to conversation history and user data
  • Potential API cost exposure

OpenClaw takes security seriously with multiple layers of protection. Let’s configure them properly for Azure.


🔐 Layer 1: Gateway Authentication Token

The gateway token is the first line of defense. It’s auto-generated during docker-setup.sh and stored in .env:

cd ~/openclaw
grep OPENCLAW_GATEWAY_TOKEN .env

Best practices

  • Never share the token in plain text
  • Rotate it periodically:
    # Generate a new token
    NEW_TOKEN=$(openssl rand -hex 32)
    echo "New token: $NEW_TOKEN"
    
    # Update .env
    sed -i "s/OPENCLAW_GATEWAY_TOKEN=.*/OPENCLAW_GATEWAY_TOKEN=$NEW_TOKEN/" .env
    
    # Restart
    docker compose down
    docker compose up -d
  • Use a strong token — at least 32 hex characters

📱 Layer 2: Device Pairing

OpenClaw requires browsers to pair with the gateway before accessing the Control UI. This creates a device identity tied to the browser’s secure context.

How device pairing works

  1. Browser requests access → generates a device identity (requires HTTPS or localhost)
  2. Gateway stores the request as “pending”
  3. Operator approves via CLI
  4. Browser is paired and can authenticate

Managing devices

# List all paired and pending devices
docker compose run --rm openclaw-cli devices list

# Approve a pending device
docker compose run --rm openclaw-cli devices approve <requestId>

# Revoke a device (if supported)
docker compose run --rm openclaw-cli devices list

Break-glass access

If you’re locked out and can’t pair (e.g., no HTTPS, no localhost):

# Generate a direct dashboard URL with token
docker compose run --rm openclaw-cli dashboard --no-open

Warning: The following flags should only be used temporarily for debugging:

  • gateway.controlUi.allowInsecureAuth — allows token-only auth over HTTP
  • gateway.controlUi.dangerouslyDisableDeviceAuth — disables device checks entirely

🌐 Layer 3: Network Security (Azure NSG)

Azure Network Security Groups (NSGs) are your perimeter defense.

PriorityNamePortSourceAction
1000AllowSSH22Your IPAllow
1001AllowOpenClaw18789-18790Your IPAllow
65000DenyAll**Deny

Setting up via Azure CLI

# Allow SSH from your IP only
az network nsg rule create \
  --resource-group rg-openclaw \
  --nsg-name vm-openclaw-01NSG \
  --name AllowSSH \
  --priority 1000 \
  --destination-port-ranges 22 \
  --source-address-prefixes "<YOUR_IP>" \
  --protocol Tcp --access Allow

# Allow OpenClaw from your IP only (skip if using SSH tunnel)
az network nsg rule create \
  --resource-group rg-openclaw \
  --nsg-name vm-openclaw-01NSG \
  --name AllowOpenClaw \
  --priority 1001 \
  --destination-port-ranges 18789 18790 \
  --source-address-prefixes "<YOUR_IP>" \
  --protocol Tcp --access Allow

If using SSH tunnel only

You don’t need the OpenClaw NSG rule at all — just allow SSH:

OPENCLAW_GATEWAY_BIND=loopback  # in .env

🔒 Layer 4: CORS Origin Enforcement

When the gateway binds to non-loopback, OpenClaw enforces browser origin checks.

docker compose run --rm openclaw-cli config set \
  gateway.controlUi.allowedOrigins \
  '["https://openclaw.yourdomain.com"]'

Dangerous flags to avoid in production

FlagRisk LevelWhat it does
dangerouslyAllowHostHeaderOriginFallbackHighTrusts Host header for origin checks
dangerouslyDisableDeviceAuthCriticalDisables device identity checks entirely
allowInsecureAuthMediumAllows token-only auth without device pairing

For production deployments with remote access, HTTPS is the gold standard. Tailscale Serve is the easiest way to add HTTPS to OpenClaw:

Install Tailscale on the VM

curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up

Expose OpenClaw via Tailscale Serve

sudo tailscale serve https / http://127.0.0.1:18789

Now access the Control UI at:

https://<your-machine-name>.<your-tailnet>.ts.net/

Benefits:

  • Automatic HTTPS certificates
  • No public ports needed
  • Device authentication works properly (secure context)
  • Access from any Tailscale-connected device

🔍 Layer 6: Built-in Security Audit

OpenClaw includes a security audit command that checks your configuration:

docker compose run --rm openclaw-cli security audit

This command checks for:

CheckSeverityWhat it flags
Missing allowed originsCriticalNon-loopback UI without origin allowlist
Host-header fallback enabledWarning/CriticalDNS rebinding risk
Insecure auth enabledWarningToken-only auth without device pairing
Device auth disabledCriticalNo device identity checks
Missing gateway authWarningNo token/password on gateway
Loopback without authInfoLocalhost-only but no token

Example audit output

The audit will report findings with severity levels and remediation suggestions. Address all critical findings before going to production.


📋 Security Checklist

Before running OpenClaw in production on Azure:

  • Gateway token is strong (32+ hex chars) and stored securely
  • .env file has restricted permissions (chmod 600 .env)
  • NSG rules restrict access to your IP(s) only
  • Bind mode is loopback (SSH tunnel) or lan with explicit allowedOrigins
  • No dangerous* flags enabled in production
  • Device pairing is active (not disabled)
  • security audit reports no critical findings
  • Bot tokens (Discord, etc.) are valid and not exposed
  • HTTPS via Tailscale Serve or reverse proxy (for remote access)
  • Regular token rotation schedule established

⏭️ Next Steps

Now let’s look at common deployment issues: Troubleshooting OpenClaw Docker Deployments.

Share:

Luca Berton

AI & Cloud Advisor with 18+ years experience. Author of 8 technical books, creator of Ansible Pilot. Speaker at KubeCon EU & Red Hat Summit 2026.

Luca Berton Ansible Pilot Ansible by Example Open Empower K8s Recipes Terraform Pilot CopyPasteLearn ProteinLens TechMeOut