openclaw安全加固

1.修改配置文件的方式进行风险加固

1.1 渠道的群组权限太开放

  • 你的 Telegram 群组策略设为 `open`,但启用了高权限工具

  • 风险:群组里的恶意提示注入可能触发危险操作

  • 修复:改为 `allowlist` 模式,或限制群组能用的工具

例:

bash 复制代码
{
  "telegram": {
    "groupPolicy": "open",
    "allowedTools": ["execute_command", "read_file", "write_file", "web_search"]
  }
}

修复命令:

bash 复制代码
# 编辑配置文件
nano ~/.config/openclaw/openclaw.json

# 或者使用命令行设置
openclaw config set telegram.groupPolicy allowlist
openclaw config set telegram.allowedGroups --json '["-1001234567890"]'

修复后:

bash 复制代码
{
  "telegram": {
    "groupPolicy": "allowlist",
    "allowedGroups": ["-1001234567890", "-1009876543210"],
    "allowedTools": ["web_search", "read_file"],
    "toolPermissions": {
      "read_file": {
        "allowedPaths": ["/workspace/*", "/tmp/*"]
      }
    }
  }
}

1.2 文件/系统工具暴露

  • 开放群组可以访问执行命令、读写文件等工具

  • 风险:提示注入可能导致命令执行或文件修改

  • 修复:对开放群组限制为仅消息工具,文件系统限制为仅工作区

例:

bash 复制代码
{
  "tools": {
    "execute_command": { "enabled": true },
    "write_file": { "enabled": true },
    "read_file": { "enabled": true }
  }
}

修复命令:

bash 复制代码
# 禁用群组中的危险工具
openclaw config set tools.execute_command.enabled false
openclaw config set tools.write_file.restrictedToWorkspace true
openclaw config set tools.read_file.restrictedToWorkspace true

修复后:

bash 复制代码
{
  "tools": {
    "execute_command": {
      "enabled": false,
      "groups": {
        "allowlist": []
      }
    },
    "write_file": {
      "enabled": true,
      "restrictedToWorkspace": true,
      "allowedPaths": ["/mnt/kimi/output/*"],
      "denyPaths": ["/etc/*", "/root/*", "~/.ssh/*", "*.pem", "*.key"]
    },
    "read_file": {
      "enabled": true,
      "restrictedToWorkspace": true,
      "allowedPaths": ["/mnt/kimi/upload/*", "/mnt/kimi/output/*"]
    }
  }
}

2.使用沙箱部署

使用容器docker部署openclaw。

MAC安装docker地址:

https://docs.docker.com/desktop/setup/install/mac-install/

安装完成后,因为是 Docker Hub 的官方镜像仓库地址是国外的,需要修改成国内:

打开Docker Desktop --- 打开 Settings (设置)--- 选择 Docker Engine--- 在 JSON 配置中添加json配置:

bash 复制代码
{
  "registry-mirrors": [
    "https://docker.mirrors.ustc.edu.cn",
    "https://hub-mirror.c.163.com"
  ]
}

如:

bash 复制代码
{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "registry-mirrors": [
    "https://docker.mirrors.ustc.edu.cn",
    "https://hub-mirror.c.163.com",
    "https://docker.m.daocloud.io"
  ]
}
  1. 点击 Apply & Restart。

  2. 配置openclaw使用docker部署,运行openclaw,在docker的container中可以看到openclaw的部署运行情况。

相关推荐
SP八岐大兔3 小时前
AI对话&OpenClaw全域终极指令大全
网络·人工智能·openclaw
key_3_feng5 小时前
OpenClaw本地部署方案:硬件配置与环境搭建全指南
openclaw
key_3_feng5 小时前
手动部署OpenClaw常见错误问题集锦
openclaw
江西省遂川县常驻深圳大使6 小时前
openclaw.json配置示例
服务器·json·openclaw
bingyan03718 小时前
openclaw-常用命令合集
常用命令·openclaw
七夜zippoe9 小时前
腾讯云轻量服务器部署OpenClaw实战:打造智能日程管理助手
服务器·云计算·腾讯云·openclaw·腾讯云openclaw玩虾大赛
真心喜欢你吖10 小时前
OpenClaw安装部署Mac操作系统版 - 打造你的专属AI助理
java·人工智能·macos·ai·语言模型·智能体·openclaw
青芒.11 小时前
OpenClaw 微信插件(ClawBot)安装失败全解析:`fetch failed`、Gateway 未启动、Hosts 干扰等问题一站式解决
openclaw
乱世刀疤12 小时前
OpenClaw Memory 使用指南
人工智能·openclaw
郑板桥3012 小时前
本地部署 OpenClaw(小龙虾)后,热门 Skills 的安装与实战手册
openclaw