安全
OpenClaw 安全最佳实践。
安全审计
运行安全审计:
bash
openclaw security audit
openclaw security audit --deep
openclaw security audit --fix认证
始终启用认证
即使本地部署也应启用认证:
json
{
"gateway": {
"auth": {
"token": "strong-random-token"
}
}
}强密码/Token
- 使用至少 32 字符的随机 token
- 不要使用可猜测的密码
- 定期轮换
访问控制
限制发送者
json
{
"channels": {
"whatsapp": {
"allowFrom": ["+15551234567"],
"dmPolicy": "allowlist"
}
}
}群组访问
json
{
"channels": {
"whatsapp": {
"groups": {
"*": {
"requireMention": true
}
}
}
}
}沙箱
启用沙箱限制智能体能力:
json
{
"agents": {
"defaults": {
"sandbox": {
"enabled": true,
"mode": "docker"
}
}
}
}参见 沙箱。
工具策略
限制危险工具:
json
{
"agents": {
"defaults": {
"toolPolicy": {
"elevated": ["system.run", "browser.*"],
"disabled": ["exec.sudo"]
}
}
}
}网络安全
绑定模式
loopback- 仅本地(最安全)tailnet- Tailscale 网络lan- 局域网- 避免绑定到公网
TLS
远程访问应启用 TLS:
json
{
"gateway": {
"tls": {
"enabled": true,
"cert": "/path/to/cert.pem",
"key": "/path/to/key.pem"
}
}
}提示注入防护
- 使用强模型(更好的指令遵循)
- 限制工具权限
- 审查敏感操作
- 不公开给不受信任的用户
文件权限
确保配置文件权限:
bash
chmod 600 ~/.openclaw/openclaw.json
chmod 700 ~/.openclaw/