介绍
# secucheck - OpenClaw Security Audit
用于 OpenClaw 部署的综合安全审计技能。分析配置、权限、暴露风险和运行时环境,并提供上下文感知的建议。
---
## 摘要
**secucheck** 对您的 OpenClaw 设置执行只读安全审计:
- **7 个审计域**:运行时、频道、代理、Cron 作业、技能、会话、网络 - **3 种专业水平**:初级(类比)、中级(技术)、专家(攻击向量) - **上下文感知**:考虑 VPN、单用户、自托管场景 - **运行时检查**:实时系统状态(网络暴露、容器、权限) - **仪表板**:包含安全评分的可视化 HTML 报告 - **本地化输出**:最终报告匹配用户语言
**绝不自动修改配置。** 所有修复均需用户明确确认。
---
## 快速开始
### 安装 ```bash clawhub install secucheck ```
### 用法
询问您的 OpenClaw 代理: - “security audit” - “secucheck” - “run security check”
### 专业水平
提示时,选择您的级别: 1. **初级** - 简单的类比,无行话 2. **中级** - 技术细节,配置示例 3. **专家** - 攻击向量,边缘情况,CVE
所有级别执行相同的检查——仅解释深度不同。
### 仪表板 ``` "show dashboard" / "visual report" ``` 在浏览器中打开 HTML 报告。
---
## 示例输出
``` 🔒 Security Audit Results
🟡 Needs Attention
| Severity | Count | |----------|-------| | 🔴 Critical | 0 | | 🟠 High | 0 | | 🟡 Medium | 2 | | 🟢 Low | 3 |
### 🟡 Agent "molty": exec + external content processing ... ```
---
## 功能
- 🔍 **全面性**:频道、代理、Cron、技能、会话、网络、运行时 - 👤 **3 种专业水平**:初级 / 中级 / 专家 - 🌏 **本地化**:用户语言的最终报告 - 🎯 **攻击场景**:真实世界的利用路径 - ⚡ **运行时检查**:VPN、容器、权限、网络暴露 - 🎨 **仪表板**:包含安全评分的可视化 HTML 报告
---
# 代理指令
*以下所有内容均用于执行此技能的代理。*
---
## 何时使用
在以下情况触发此技能: - 用户请求安全检查/审计 - **自动触发**:安装技能、创建/修改代理、添加/修改 Cron 作业 - 定期审查(建议:每周)
## 专业水平
| 级别 | 标识符 | 风格 | |-------|------------|-------| | 初级 | `1`, `beginner` | 类比,简单解释,无行话 | | 中级 | `2`, `intermediate` | 技术细节,配置示例 | | 专家 | `3`, `expert` | 攻击向量,边缘情况,CVE 引用 |
## 执行流程
### 第一步:询问级别(在运行任何操作之前)
用用户的语言展示选项。示例(英语):
``` What level of technical detail do you prefer?
1. 🌱 Beginner - I'll explain simply with analogies 2. 💻 Intermediate - Technical details and config examples 3. 🔐 Expert - Include attack vectors and edge cases
📌 All levels run the same checks—only explanation depth varies. ```
**在此停止。等待用户响应。**
### 第二步:运行审计
```bash bash ~/.openclaw/skills/secucheck/scripts/full_audit.sh ```
返回按严重程度分类的发现 JSON。
### 第三步:格式化输出
解析 JSON 输出并根据用户的专业水平进行格式化。 **最终报告必须使用用户的语言。**
#### 报告结构(按类别组织)
``` 🔒 Security Audit Results
📊 Summary Table | Severity | Count | |----------|-------| | 🔴 Critical | X | | ...
⚡ Runtime - [findings related to RUNTIME category]
🤖 Agents - [findings related to AGENT category]
📁 Workspace - [findings related to WORKSPACE category]
🧩 Skills - [findings related to SKILL category]
📢 Channels - [findings related to CHANNEL category]
🌐 Network - [findings related to NETWORK category] ```
按 `category` 字段对发现进行分组,而不仅仅是按严重程度。 在每个类别中,显示严重程度图标并进行解释。
### 第四步:自动打开仪表板
文本报告之后,自动生成并提供仪表板:
```bash bash ~/.openclaw/skills/secucheck/scripts/serve_dashboard.sh ```
脚本返回包含 `url`(LAN IP)和 `local_url`(localhost)的 JSON。 **在告知用户时使用 `url` 字段(而非 localhost)**——他们可能从其他设备访问。
示例: ``` 📊 대시보드도 열었어요: http://192.168.1.200:8766/secucheck-report.html ```
如果在可以打开浏览器的环境中运行,请使用浏览器工具将其打开。
## 跨平台支持
脚本在 Linux、macOS 和 WSL 上运行。检查 JSON 输出以获取平台信息:
```json { "os": "linux", "os_variant": "ubuntu", "in_wsl": false, "in_dsm": false, "failed_checks": ["external_ip"] } ```
### 平台检测
| 字段 | 值 | |-------|--------| | `os` | `linux`, `macos`, `windows`, `unknown` | | `os_variant` | `ubuntu`, `arch`, `dsm`, `wsl`, 版本字符串 | | `in_wsl` | 如果在 Linux 子系统 (WSL) 中则为 `true` | | `in_dsm` | 如果在 Synology DSM 中则为 `true` |
### 处理失败的检查
如果 `failed_checks` 数组非空,请根据平台运行回退命令:
#### 网络信息回退
| 平台 | 命令 | |----------|---------| | Linux | `ip addr show` 或 `ifconfig` | | macOS | `ifconfig` | | WSL | `ip addr show`(或通过 `cmd.exe /c ipconfig` 检查 Windows)| | Windows | PowerShell: `Get-NetIPAddress` | | DSM | `ifconfig` 或 `/sbin/ip addr` |
#### 网关绑定回退
| 平台 | 命令 | |----------|---------| | Linux | `ss -tlnp \| grep :18789` 或 `netstat -tlnp` | | macOS | `lsof -iTCP:18789 -sTCP:LISTEN` | | Windows | PowerShell: `Get-NetTCPConnection -LocalPort 18789` |
#### 文件权限回退
| 平台 | 命令 | |----------|---------| | Linux/macOS | `ls -la ~/.openclaw` | | Windows | PowerShell: `Get-Acl $env:USERPROFILE\.openclaw` |
### Windows 原生支持
如果 `os` 为 `windows` 且脚本完全失败:
1. 直接使用 PowerShell 命令: ```powershell # Network exposure Get-NetTCPConnection -LocalPort 18789 -State Listen
# File permissions Get-Acl "$env:USERPROFILE\.openclaw"
# Process info Get-Process | Where-Object {$_.Name -like "*openclaw*"} ```
2. 报告您可以检查的内容并注明 Windows 特定的限制。
### 极简环境(Docker, DSM)
某些环境缺少工具。检查输出并进行补充:
| 缺失工具 | 回退 | |--------------|----------| | `curl` | `wget -qO-` | | `ss` | `netstat` | | `ip` | `ifconfig` 或 `/sbin/ip` | | `pgrep` | `ps aux \| grep` |
### 代理决策流程
``` 1. Run full_audit.sh 2. Check "failed_checks" in output 3. For each failed check: a. Identify platform from os/os_variant b. Run platform-specific fallback command c. Incorporate results into report 4. Note any checks that couldn't complete ```
## 仪表板生成
当用户请求可视化报告时:
```bash bash ~/.openclaw/skills/secucheck/scripts/serve_dashboard.sh ```
返回: ```json { "status": "ok", "url": "http://localhost:8766/secucheck-report.html", "pid": 12345 } ```
直接向用户提供 URL。
## 详细检查参考
仅在需要深入解释时阅读:
| 文件 | 域 | |------|--------| | `checks/runtime.md` | 实时系统状态 | | `checks/channels.md` | 频道策略 | | `checks/agents.md` | 代理权限 | | `checks/cron.md` | 计划作业 | | `checks/skills.md` | 已安装技能 | | `checks/sessions.md` | 会话隔离 | | `checks/network.md` | 网络配置 |
## 攻击场景模板
用于专家级解释:
| 文件 | 场景 | |------|----------| | `scenarios/prompt-injection.md` | 外部内容操作 | | `scenarios/session-leak.md` | 跨会话数据暴露 | | `scenarios/privilege-escalation.md` | 工具权限滥用 | | `scenarios/credential-exposure.md` | 密钥泄露 | | `scenarios/unauthorized-access.md` | 访问控制绕过 |
## 风险级别
``` 🔴 Critical - Immediate action required. Active exploitation possible. 🟠 High - Significant risk. Should fix soon. 🟡 Medium - Notable concern. Plan to address. 🟢 Low - Minor issue or best practice recommendation. ⚪ Info - Not a risk, but worth noting. ```
## 风险矩阵
``` Tool Permissions Minimal Full ┌──────────┬──────────┐ Exposure │ 🟢 │ 🟡 │ Low │ Safe │ Caution │ ├──────────┼──────────┤ │ 🟡 │ 🔴 │ High │ Caution │ Critical │ └──────────┴──────────┘
Exposure = Who can talk to the bot (DM policy, group access, public channels) Tool Permissions = What the bot can do (exec, file access, messaging, browser) ```
## 上下文感知例外
不要仅进行模式匹配。考虑上下文:
| 上下文 | 调整 | |---------|------------| | 私有频道,2-3 个受信任成员 | 即使有 exec,风险也较低 | | 仅 VPN/Tailscale 访问 | 网络暴露不太关键 | | 自托管,单用户 | 会话隔离不太重要 | | 容器化环境 | 权限提升严重性较低 |
如果不清楚,请始终询问环境。
## 应用修复
**关键规则:**
1. **切勿自动应用修复。** 始终先显示建议。 2. **警告功能影响。** 如果修复可能导致问题,请说明。 3. **在进行任何配置更改之前,获取用户明确确认。**
示例流程: ``` Agent: "Changing this setting will disable exec in #dev channel. If you're using code execution there, it will stop working. Apply this fix?" User: "yes" Agent: [apply fix via gateway config.patch] ```
## 语言规则
- **内部处理**:始终使用英语 - **思考/推理**:始终使用英语 - **最终面向用户的报告**:匹配用户语言 - **技术术语**:保留英语(exec、cron、gateway 等)
## 自动审查触发器
在以下情况下自动调用:
1. **技能安装**:`clawhub install <skill>` 或手动添加 2. **代理创建/修改**:新代理或工具更改 3. **Cron 作业创建/修改**:新的或修改的计划任务
对于自动审查,除非要求全面审计,否则仅关注已更改的组件。
## 快速命令
| 用户请求 | 操作 | |--------------|--------| | “check channels only” | 运行 channels.md 检查 | | “audit cron jobs” | 运行 cron.md 检查 | | “full audit” | 所有检查 | | “more detail” | 使用详细输出重新运行 |
## 信任层级
应用适当的信任级别:
| 级别 | 实体 | 信任模型 | |-------|--------|-------------| | 1 | 所有者 | 完全信任 — 拥有所有访问权限 | | 2 | AI 代理 | 信任但验证 — 已沙箱化,已记录 | | 3 | 白名单 | 有限信任 — 仅指定用户 | | 4 | 陌生人 | 无信任 — 默认阻止 |
## 事件响应参考
如果怀疑被入侵:
### 遏制 1. 停止网关进程 2. 将 gateway.bind 设置为回环地址 (127.0.0.1) 3. 禁用有风险的 DM/群组策略
### 轮换 1. 重新生成网关认证令牌 2. 轮换浏览器控制令牌 3. 撤销并轮换 API 密钥
### 审查 1. 检查网关日志和会话记录 2. 审查最近的配置更改 3. 重新运行全面安全审计
## 文件参考
``` ~/.openclaw/skills/secucheck/ ├── SKILL.md # This file ├── skill.json # Package metadata ├── README.md # User documentation ├── scripts/ │ ├── full_audit.sh # Complete audit (JSON output) │ ├── runtime_check.sh # Live system checks │ ├── gather_config.sh # Config extraction (redacted) │ ├── gather_skills.sh # Skill security scan │ ├── gather_agents.sh # Agent configurations │ ├── serve_dashboard.sh # Generate + serve HTML report │ └── generate_dashboard.sh ├── dashboard/ │ └── template.html # Dashboard template ├── checks/ │ ├── runtime.md # Runtime interpretation │ ├── channels.md # Channel policy checks │ ├── agents.md # Agent permission checks │ ├── cron.md # Cron job checks │ ├── skills.md # Skill safety checks │ ├── sessions.md # Session isolation │ └── network.md # Network exposure ├── scenarios/ │ ├── prompt-injection.md │ ├── session-leak.md │ ├── privilege-escalation.md │ ├── credential-exposure.md │ └── unauthorized-access.md └── templates/ ├── report.md # Full report template ├── finding.md # Single finding template └── summary.md # Quick summary template ```
## 安全评估问题
审计时,请考虑:
1. **暴露**:哪些网络接口可以访问此代理? 2. **身份验证**:每个访问点需要什么验证? 3. **隔离**:代理和主机之间存在哪些边界? 4. **信任**:哪些内容来源被视为“受信任”? 5. **可审计性**:存在哪些代理操作的证据? 6. **最小权限**:代理是否仅拥有必要的权限?
---
**请记住:** 此技能旨在让 OpenClaw 意识到其安全态势。请定期使用,根据需要进行扩展,切勿跳过审计。