开发者
资源
文档评分
获取效率
正确性
完整性
易理解
在线提单
论坛求助

工具白名单控制,禁止危险工具

工具白名单控制是OpenClaw安全加固的核心防线,通过限制Agent可调用的系统能力,防止高危操作(如删除文件、执行任意命令、修改权限)被恶意利用或误执行。

工具说明

表1 工具组说明

工具组

包含工具

风险等级

group:runtime

exec、bash、process

极高

group:fs

read、write、edit、apply_patch

group:web

web_search、web_fetch

group:ui

browser、canvas

group:sessions

sessions_list、sessions_history、sessions_send、sessions_spawn、session_status

group:memory

memory_search、memory_get

表2 必须禁止的高危工具清单

工具

风险说明

禁用必要性

exec

执行任意Shell命令,可删库、篡改系统。

必须禁止

process

管理后台进程,可终止关键服务。

必须禁止

write / edit / apply_patch

写入/修改文件,可覆盖敏感配置。

强烈建议禁止

browser

可能访问敏感网站、抓取需要登录的页面、或在攻击者诱导下执行恶意操作。

建议关闭

nodes

节点调度,默认无用。

建议关闭

canvas

绘图功能,极少使用。

建议关闭

操作步骤

  • 方式一:
    1. 使用命令进行配置,可以按需选择禁用。
      • 禁用所有高危工具。
        下述命令会禁用所有运行时操作类工具、文件系统操作、网络相关工具、UI交互工具、节点操作、画布绘图工具、应用补丁工具。
        openclaw config set tools.deny '["group:runtime","group:fs","group:web","group:ui","nodes","canvas","apply_patch"]' --json
      • 最低禁用
        下述命令仅禁用了运行时操作类工具,如exec、bash、process等。
        openclaw config set tools.deny '["group:runtime"]' --json
      • 使用预制Profile方式

        可以通过该方法进行便捷配置,根据场景选择profile。

        openclaw config set tools.profile "minimal"
        openclaw config set tools.profile "messaging"
        openclaw config set tools.profile "coding"
        profile对照表如下:

        Profile

        包含工具

        适用场景

        minimal

        仅session_status

        只读对话场景,最安全

        messaging

        消息类工具组

        聊天机器人

        coding

        开放开发相关权限:文件系统(group:fs,如read/write)、运行时(group:runtime,如exec/process)、会话(group:sessions)、网络(group:web)、内存(group:memory)、图片(image)等

        开发/代码场景

        full

        无权限限制

        本地开发、功能测试、需要完整AI能力场景

    2. 设置fs、exec加固基线。
      openclaw config set tools.fs.workspaceOnly true
      openclaw config set tools.exec.security "deny"
      openclaw config set tools.exec.ask "always"
    3. 重启OpenClaw网关。
      openclaw gateway restart
  • 方式二
    1. 打开配置文件。
      vim ~/.openclaw/openclaw.json
    2. 按“i”进入编辑模式,请参考如下内容修改,若不存在请手动添加。下列为禁用所有高危工具,请根据实际情况选择禁用。
      {
        "tools": {
          "deny": [
            "group:runtime",   // 运行时工具组 (exec, bash, process) - 最关键!
            "group:ui",        // 禁止UI交互工具,会影响TUI功能
            "group:fs",        // 禁止文件系统操作(读/写/删除文件、目录遍历等)
            "group:web",       // 禁止网络相关工具(HTTP请求、网页抓取等)
            "nodes",           // 禁止节点操作(可能是 node 管理相关工具)
            "canvas",          // 禁止画布/绘图工具
            "apply_patch"      // 禁止应用补丁工具(禁止代码修改)
          ]
        }
      }

      也可以精准禁止(最严格)直接列出需要禁用的工具,例如:

      {
        "tools": {
          "allow": [
            "read",
            "web_search",
            "web_fetch",
            "sessions_list",
            "session_status",
            "memory_search",
            "memory_get"
          ],
          "deny": [
            "exec",
            "process",
            "write",
            "edit",
            "apply_patch",
            "nodes",
            "canvas",
            "cron",
            "gateway"
          ]
        }
      }

      也可以使用预设profile方式,例如:

      {

      tools: {

      profile: "messaging",

      deny: ["group:automation", "group:runtime", "group:fs", "sessions_spawn", "sessions_send"],

      fs: { workspaceOnly: true },

      exec: { security: "deny", ask: "always" },

      elevated: { enabled: false }

      },

      }

    3. 按“Esc”键退出编辑模式,输入:wq!,按“Enter”键保存并退出文件。
    4. 重启OpenClaw网关。
      openclaw gateway restart