$ openclaw security audit
# 尝试实时探测 Gateway 网关,需要有用户身份的读取的权限,才可以。
$ openclaw security audit --deep
审计报告指出飞书群组策略设为open(允许任意成员触发操作),同时智能体配置(agents.defaults等)未启用沙箱(sandbox=off),且开放了exec(命令执行)、file.write(文件写入)等高危权限,且未隔离用户权限(如fs.workspaceOnly=false使智能体可访问全系统文件)。
- 风险实质:攻击者只需在群聊中发送恶意指令(如隐藏在文档/消息中的
curl | bash),即可绕过身份认证直接控制系统,实现数据窃取或勒索攻击。
个人在 OpenClaw 2026.7.1 上实践结果
每个人使用诉求不一样,请根据自己的情况调整。
# 按渠道 + 发送者隔离私信
$ openclaw config set session.dmScope "per-channel-peer"
# 全局只能聊天,且只能访问工作空间的文件;再加上在没有sudo权限的用户下,运行 OpenClaw,就不需要去指定 exec、elevated、deny,不然把agents.tools配置搞复杂了。
$ openclaw config set tools.profile "messaging"
$ openclaw config set tools.fs.workspaceOnly true
# 对指定的agent,区分不同权限。如果还需要缩小权限,使用 allow 指定可用范围;如果还需要扩大权限,使用 alsoAllow 叠加式增加。
$ openclaw config set agents.list[1].tools.profile "coding"
$ openclaw config set agents.list[1].tools.fs.workspaceOnly false
配置效果:
"session": {
"dmScope": "per-channel-peer"
},
"tools": {
"profile": "messaging",
"fs": { "workspaceOnly": true }
},
"agents": {
"list": [
{ "id": "main" },
{
"id": "coding",
"tools": {
"profile": "coding",
"fs": { "workspaceOnly": false }
}
}
},
更多 tools 内容
60 秒内完成加固基线配置:此配置将 Gateway 网关限制为仅本地访问、隔离私信,并默认禁用控制平面/运行时工具。在此基础上,仅为受信任的智能体有选择地重新启用工具。
{
gateway: {
mode: "local",
bind: "loopback",
auth: { mode: "token", token: "replace-with-long-random-token" },
},
session: {
dmScope: "per-channel-peer",
},
tools: { // 注释了很多,也是为了方便对agent单独放开权限。
// profile 值为 minimal、messaging、coding、full,代表不同预定义的权限范围
// tools.profile 是全局的,可以在 agents.list[].tools.profile 单独指定不同权限
profile: "messaging",
// 限制高危工具组:`group:fs` 和 `group:runtime` 是导致文件篡改/服务器沦陷的主因,但 messaging 本来就不包含这些,可以注释
deny: ["group:automation", "group:runtime", "group:fs", "sessions_spawn", "sessions_send"],
// 强制文件操作隔离:文件操作仅限智能体工作目录内,避免通过 file.write 覆盖任意系统配置文件
fs: { workspaceOnly: true },
// 锁定命令执行权限:由于限制了fs,可以注释
exec: { security: "deny", ask: "always" },
// 关闭提升权限功能:由于在无sudo用户下运行openclaw,可以注释
elevated: { enabled: false },
},
channels: {
whatsapp: { dmPolicy: "pairing", groups: { "*": { requireMention: true } } },
},
}
工具:全局 profile 与 组
工具概览 – OpenClaw、配置——工具和自定义提供商 – OpenClaw
不能在同一作用域同时设置 allow 和 alsoAllow。
- allow = 替换式白名单(收紧,只能比 profile 更少)
- alsoAllow = 叠加式追加(在 profile 基线上加几个)
| profile | 包含权限 |
|---|---|
| minimal | 仅 session_status<br>仅开放会话状态 |
| messaging | group:messaging、sessions_list、sessions_history、sessions_send、session_status<br>仅开放消息相关权限 |
| coding | group:fs、group:runtime、group:web、group:sessions、group:memory、cron、get_goal、create_goal、update_goal、update_plan、skill_workshop、image、image_generate、music_generate、video_generate<br>开放了文件系统、运行时、会话、内存、图片相关权限等等,与full有差异。 |
| full | 无限制(与未设置相同) |
coding 和 messaging 还会隐式允许 bundle-mcp(已配置的 MCP 服务器)。
| 工具组 | 工具 |
|---|---|
| group:runtime | exec、process、code_execution(接受 bash 作为 exec 的别名) |
| group:fs | read、write、edit、apply_patch |
| group:sessions | sessions_list、sessions_history、sessions_send、sessions_spawn、sessions_yield、subagents、session_status |
| group:memory | memory_search、memory_get |
| group:web | web_search、x_search、web_fetch |
| group:ui | browser、canvas |
| group:automation | heartbeat_respond、cron、gat</font>eway |
| group:messaging | message |
| group:nodes | nodes、computer |
| group:agents | </font>agents_list、get_goal、create_goal、update_goal、update_plan、skill_workshop |
| group:media | image、image_generate、music_generate、video_generate、tts |
| group:openclaw | 大多数 OpenClaw 内置工具(不包括 read/write/edit/apply_patch/exec/process 文件系统及运行时原语、canvas 和提供商插件) |
| group:plugins | 所有已加载且归插件所有的工具,包括通过 bundle-mcp 暴露的已配置 MCP 服务器 |
60 秒内完成加固基线配置的工具部分,执行命令
# 单次执行
$ openclaw config set tools.profile "messaging"
$ openclaw config set tools.deny '["group:automation", "group:runtime", "group:fs", "sessions_spawn", "sessions_send"]'
$ openclaw config set tools.fs.workspaceOnly true
$ openclaw config set tools.exec.security "deny"
$ openclaw config set tools.exec.ask "always"
$ openclaw config set tools.elevated.enabled false
# 批量执行:不建议,本质是替换 tools 节点内容,会导致其他配置丢失,比如:tavily。还不如将复制以上多行,一次粘贴执行。
$ openclaw config set 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}}'
工具:放宽指定Agnet
# 让 第二个 agent 有 coding 所有权限
$ openclaw config set agents.list[1].tools.profile "coding"
$ openclaw config unset tools.deny
$ openclaw config set agents.list[1].tools.deny '[]'
$ openclaw config set agents.list[1].tools.allow '["group:runtime","group:fs","group:sessions","group:memory","group:web","group:ui","group:automation","group:messaging","group:nodes","group:agents","group:media","group:openclaw","group:plugins"]'
$ openclaw config set agents.list[1].tools.fs.workspaceOnly false
$ openclaw config set agents.list[1].tools.exec.security "full"
$ openclaw config set agents.list[1].tools.exec.ask "off"
$ openclaw config set agents.list[1].tools.elevated.enabled true
$ openclaw config get agents.list[1]
发表回复
要发表评论,您必须先登录。