Skip to main content

安全概述

OpenClaw 是一个强大的自主代理系统,安全性是设计的核心。

威胁模型

完整的威胁模型和设计边界请参阅:

安全原则

1. 默认安全

  • 网关默认绑定回环地址(127.0.0.1
  • 非回环地址绑定必须配置认证
  • 频道默认需要配对/白名单

2. 最小权限原则

  • 执行审批系统控制 system.run
  • 工具访问控制(允许/拒绝列表)
  • 节点权限管理

3. 深度防御

  • 多层认证(令牌 + 密码 + 设备配对)
  • 速率限制
  • 输入验证
  • 内容安全策略

认证

网关认证

网关支持多种认证模式:
  • 令牌(推荐):gateway.auth.token
  • 密码gateway.auth.password
  • Tailscalegateway.auth.allowTailscale
{
  gateway: {
    auth: {
      mode: "token",
      token: "${OPENCLAW_GATEWAY_TOKEN}"
    }
  }
}

频道认证

每个频道可以配置:
  • 白名单allowFrom 限制允许的发送者
  • DM 策略dmPolicy 控制私信访问
  • 配对:设备配对系统
{
  channels: {
    whatsapp: {
      dmPolicy: "allowlist",
      allowFrom: ["+1234567890"]
    }
  }
}

执行控制

执行审批

system.run 由执行审批系统控制:
{
  "version": 1,
  "defaults": {
    "security": "deny",
    "ask": "on-miss"
  },
  "agents": {
    "main": {
      "security": "allowlist",
      "allowlist": [{ "pattern": "/opt/homebrew/bin/*" }]
    }
  }
}

工具访问控制

{
  tools: {
    allow: ["browser", "exec", "message"],
    deny: ["elevated"]
  }
}

网络安全

绑定模式

  • loopback(默认):仅本地访问
  • lan:局域网访问(需要认证)
  • tailnet:Tailscale 网络访问(需要认证)
{
  gateway: {
    bind: "loopback",
    port: 18789
  }
}

Tailscale Serve

推荐使用 Tailscale Serve 进行远程访问:
openclaw gateway --tailscale serve
这提供:
  • HTTPS 加密
  • Tailscale 身份验证
  • 自动证书管理

数据安全

本地存储

所有数据默认本地存储在 ~/.openclaw/
  • 配置:openclaw.json
  • 凭据:credentials/
  • 会话:agents/<agentId>/sessions/
  • 日志:gateway.log

文件权限

Doctor 会检查并警告不安全的文件权限:
chmod 600 ~/.openclaw/openclaw.json
chmod 700 ~/.openclaw/credentials/

最佳实践

1. 使用强令牌

openssl rand -hex 32

2. 启用执行审批

在 macOS 应用设置中配置执行审批。

3. 限制频道访问

使用白名单限制允许的发送者。

4. 定期审计

openclaw logs --follow
cat ~/.openclaw/logs/commands.log

5. 保持更新

openclaw update

安全报告

如果您发现安全漏洞,请通过以下方式报告:
  • 私下联系维护者
  • 使用 GitHub Security Advisories
请勿公开披露安全漏洞。

相关文档