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的部署运行情况。

相关推荐
bdy_y921 分钟前
agent-browser总是启动失败?DevToolsActivePort ?深入排查解决错误的完整指南
openclaw
韩明君2 小时前
OpenClaw安全部署实现
linux·人工智能·安全·debian·本地部署·ai agent·openclaw
bingyan03713 小时前
openclaw-基于飞书的多agent自主交互配置
飞书·配置·多agent·openclaw
翔云1234564 小时前
OpenClaw记忆系统
大模型·openclaw
xierui1231235 小时前
“探索型 AI“和“交付型AI“是两个完全不同的物种 [特殊字符]
人工智能·ai agent·ai工具·manus·openclaw·养虾·ai科普
好运的阿财14 小时前
OpenClaw工具拆解之canvas+message
人工智能·python·ai编程·openclaw·openclaw工具
AC赳赳老秦15 小时前
OpenClaw二次开发实战:编写专属办公自动化技能,适配个性化需求
linux·javascript·人工智能·python·django·测试用例·openclaw
阿杰学AI19 小时前
AI核心知识135—大语言模型之 OpenClaw(简洁且通俗易懂版)
人工智能·ai·语言模型·自然语言处理·aigc·ai编程·openclaw
想ai抽1 天前
Harness模式下的Agent记忆架构设计剖析:原理、权衡与场景适配(引言)
agent·openclaw·harness
AC赳赳老秦1 天前
OpenClaw与Excel联动:批量读取/写入数据,生成可视化报表
开发语言·python·excel·产品经理·策略模式·deepseek·openclaw