clawd-zero-trust (v1.3.1)
Zero Trust hardening framework for OpenClaw. Built by Blocksoft.
⚠️ BREAKING (v1.3.0→v1.3.1): First apply after upgrade requires --force or run bash scripts/release-gate.sh --reset-hash to reset trusted baseline. Unattended/cron apply workflows must be updated.
Dependencies
The following binaries are required. Install with apt on Debian/Ubuntu:
| Binary | Package | Required For |
|---|
| INLINECODE3 | INLINECODE4 | All mutating operations (--apply, --canary, --reset, --refresh) |
| INLINECODE9 |
curl | Endpoint verification (
--verify,
--verify-all) |
|
openssl |
openssl | SMTP/IMAP verification in
--verify-all |
|
nc |
netcat-openbsd | TCP/UDP port checks in
--verify-all |
|
dig |
dnsutils | DNS resolution for provider IPs |
|
python3 |
python3 | JSON parsing, log aggregation, state management |
Read-only modes (--verify, --audit-log, --status) do not require root. Mutating modes (--apply, --canary, --reset, --refresh) require root privileges.
Core Principles
- 1. NHI (Non-Human Identity): Sub-agents run as isolated sessions with scoped credentials. Never share 'main' identity for high-risk ops.
- PLP (Principle of Least Privilege): Restrict default model toolset. Use
tools.byProvider to limit small/untrusted models to coding profile. - Plan-First: Declare intent (what + why + expected outcome) before any write, exec, or network call.
- Egress Control: Whitelist outbound traffic to authorized AI providers only. Preserve Tailscale + Telegram API.
- Assumption of Breach: Design as if the attacker is already in. Verify every plugin, model, and extension.
Canonical Egress Script Path
Single source of truth:
INLINECODE32
Compatibility symlink:
INLINECODE33
Workflow: Audit → Harden → Egress → Verify
1) Audit
CODEBLOCK0
2) Harden
CODEBLOCK1
3) Egress Policy (dry-run default)
CODEBLOCK2
4) Egress Profile Status (v1.3.0)
# Print current egress profile status (read-only, no root required)
bash scripts/egress-filter.sh --status
Displays: profile version, last applied timestamp, last result, provider count from
providers.txt, and current UFW state. Read-only. No root required for core status output. UFW active state is best-effort — may show 'unknown' if sudo is unavailable on your system.
5) Egress Violation Audit Log (v1.3.0)
# View blocked outbound traffic from the last 24 hours
bash scripts/egress-filter.sh --audit-log
Parses
/var/log/ufw.log and
journalctl -k for
[UFW BLOCK] entries with outbound markers (
OUT=,
DPT=). Aggregates by destination IP + port and prints a summary table with counts, first-seen, and last-seen timestamps. During
--apply, a UFW LOG rule (
ZT:egress-violation) is automatically inserted to capture future violations.
6) IP Snapshot Auto-Refresh (v1.3.0)
# Re-resolve DNS and apply only changed IPs (delta) to UFW
bash scripts/egress-filter.sh --refresh
Re-resolves all domains in
config/providers.txt, diffs against the last-applied IP snapshot (
.state/applied-ips.json), and applies only the delta rules. Transactional: backs up UFW rules before applying, verifies critical endpoints after, and rolls back on failure. The IP snapshot is saved automatically after every
--apply and
--canary.
7) Per-Provider Verification (v1.3.0)
# Protocol-aware verification of ALL providers in providers.txt
bash scripts/egress-filter.sh --verify-all
Detects the appropriate protocol from port number and runs the matching check:
- - 443 → HTTPS
curl (status code check) - 587/465/25 → SMTP
openssl s_client (STARTTLS/TLS) - 993/143 → IMAP
openssl s_client (TLS/STARTTLS) - 41641 → UDP
nc -zu (Tailscale WireGuard) - 22 → TCP
nc -z (SSH) - other → TCP
nc -z (generic fallback)
Each check runs with a hard timeout 5s wrapper (enforced at OS level, not just socket timeout). Automatically called after --apply and --canary. Available standalone for on-demand verification. Requires: curl, openssl, nc (netcat-openbsd).
8) Plugin Integrity Hashing (v1.3.0)
# Snapshot current plugin hashes
bash scripts/plugin-integrity.sh --snapshot
# Verify plugin integrity against stored hashes
bash scripts/plugin-integrity.sh --verify
# Check plugins against hardening.json allowlist
bash scripts/plugin-integrity.sh --drift
# Combine checks
bash scripts/plugin-integrity.sh --verify --drift
Monitors plugin file integrity via SHA-256 hashing of each plugin's JS entry point (
dist/index.js →
index.js →
*.js fallback). Detects unauthorized modifications, new/removed plugins, and drift from the
hardening.json allowlist.
9) Dynamic Whitelisting (MAX USER-FRIENDLY API)
To open a new port or add a service securely (e.g. for custom email, video extraction, new AI agents),
DO NOT edit the bash script or hardcoded arrays. Always use the dynamic configuration helper command:
bash scripts/whitelist.sh <domain> <port>
(Example: bash whitelist.sh youtu.be 443). This automatically injects the domain cleanly into the config/providers.txt engine, triggers a transactional configuration flush, and instantly applies the changes to UFW.
10) Release Gate (v1.3.0)
bash scripts/release-gate.sh
Gate checks (must all pass):
- -
quick_validate.py on skill structure - INLINECODE65 on all shell scripts (fails with install hint if missing)
- INLINECODE66 packaging to INLINECODE67
- INLINECODE68 endpoint checks
Versioned Firewall Profile State
State files (in .state/):
| File | Purpose |
|---|
| INLINECODE70 | Script hash, version, last apply result |
| INLINECODE71 |
Per-domain IP snapshot for
--refresh delta |
|
plugin-hashes.json | SHA-256 hashes for plugin integrity verification |
On apply/canary, hash mismatch is refused unless --force is provided. The whitelist.sh helper intrinsically handles hash mismatches seamlessly.
References
- -
references/zero-trust-principles.md — Detailed ZT framework for AI agents - INLINECODE77 — Verified safe patterns that trigger audit warnings
HARD REQUIREMENT: Self-Update Prevention
NEVER run openclaw update, openclaw upgrade, npm install -g openclaw, or npm update -g openclaw without explicit Founder approval.
These commands are blocked in denyCommands. On 2026-02-24, a self-update during an audit caused a 10,450+ crash-loop by deprecating a plugin. System stability > latest version. Always:
- 1. Present update details + changelog to Founder first
- Backup config: INLINECODE83
- Only update after explicit approval
- Run
openclaw doctor --fix + openclaw status after
MANDATORY: Update Proposal Format
When you detect that an OpenClaw update is available (via update-scout-daily or any other means), you MUST ALWAYS propose it in exactly this format — no exceptions:
📦 OpenClaw update available: vOLD → vNEW
To apply safely, SSH in and run:
openclaw update
/home/claw/.openclaw/workspace/scripts/post-update-repair.sh
The repair script restores all symlinks, cleans config, restarts the gateway, and runs a 6-point smoke test automatically. No other steps needed.
NEVER say "I will run the update for you" or attempt to run it yourself. The update MUST be executed by the Founder via SSH.
clawd-zero-trust (v1.3.1)
OpenClaw的零信任加固框架。由Blocksoft构建。
⚠️ 重大变更 (v1.3.0→v1.3.1): 升级后首次应用需要使用--force参数,或运行bash scripts/release-gate.sh --reset-hash重置可信基线。无人值守/cron应用工作流必须更新。
依赖项
需要以下二进制文件。在Debian/Ubuntu上使用apt安装:
| 二进制文件 | 软件包 | 用途 |
|---|
| ufw | ufw | 所有变更操作(--apply、--canary、--reset、--refresh) |
| curl |
curl | 端点验证(--verify、--verify-all) |
| openssl | openssl | --verify-all中的SMTP/IMAP验证 |
| nc | netcat-openbsd | --verify-all中的TCP/UDP端口检查 |
| dig | dnsutils | 提供商IP的DNS解析 |
| python3 | python3 | JSON解析、日志聚合、状态管理 |
只读模式(--verify、--audit-log、--status)不需要root权限。变更模式(--apply、--canary、--reset、--refresh)需要root权限。
核心原则
- 1. NHI(非人类身份): 子代理以隔离会话运行,使用限定范围的凭证。切勿为高风险操作共享主身份。
- PLP(最小权限原则): 限制默认模型工具集。使用tools.byProvider将小型/不可信模型限制为coding配置文件。
- 计划优先: 在任何写入、执行或网络调用之前声明意图(做什么+为什么+预期结果)。
- 出口控制: 仅将出站流量白名单授权给AI提供商。保留Tailscale + Telegram API。
- 假设已被攻破: 设计时假设攻击者已经进入。验证每个插件、模型和扩展。
规范出口脚本路径
单一事实来源:
/home/claw/.openclaw/workspace/skills/clawd-zero-trust/scripts/egress-filter.sh
兼容性符号链接:
/home/claw/.openclaw/workspace/scripts/egress_filter.sh -> .../skills/clawd-zero-trust/scripts/egress-filter.sh
工作流:审计 → 加固 → 出口 → 验证
1) 审计
bash
bash scripts/audit.sh
2) 加固
bash
预览(默认)
bash scripts/harden.sh
应用
bash scripts/harden.sh --apply
3) 出口策略(默认试运行)
bash
试运行预览(默认)
bash scripts/egress-filter.sh --dry-run
事务性应用:如果Telegram/GitHub/Anthropic/OpenAI检查失败则自动回滚
bash scripts/egress-filter.sh --apply
金丝雀模式:临时应用 + 120秒周期性验证,然后提交/回滚
bash scripts/egress-filter.sh --canary
仅验证关键端点(Telegram、GitHub、Anthropic、OpenAI)
bash scripts/egress-filter.sh --verify
紧急回滚
bash scripts/egress-filter.sh --reset
4) 出口配置文件状态(v1.3.0)
bash
打印当前出口配置文件状态(只读,不需要root权限)
bash scripts/egress-filter.sh --status
显示:配置文件版本、上次应用时间戳、上次结果、来自providers.txt的提供商数量以及当前UFW状态。只读。核心状态输出不需要root权限。UFW活动状态尽力而为——如果系统上无法使用sudo,可能显示unknown。
5) 出口违规审计日志(v1.3.0)
bash
查看过去24小时内被阻止的出站流量
bash scripts/egress-filter.sh --audit-log
解析/var/log/ufw.log和journalctl -k中带有出站标记(OUT=、DPT=)的[UFW BLOCK]条目。按目标IP+端口聚合,并打印包含计数、首次出现和最后出现时间戳的汇总表。在--apply期间,会自动插入一条UFW LOG规则(ZT:egress-violation)以捕获未来的违规行为。
6) IP快照自动刷新(v1.3.0)
bash
重新解析DNS并仅将更改的IP(增量)应用到UFW
bash scripts/egress-filter.sh --refresh
重新解析config/providers.txt中的所有域名,与上次应用的IP快照(.state/applied-ips.json)进行差异比较,并仅应用增量规则。事务性:在应用前备份UFW规则,之后验证关键端点,失败时回滚。每次--apply和--canary后自动保存IP快照。
7) 按提供商验证(v1.3.0)
bash
对providers.txt中所有提供商进行协议感知验证
bash scripts/egress-filter.sh --verify-all
根据端口号检测适当的协议并运行匹配的检查:
- - 443 → HTTPS curl(状态码检查)
- 587/465/25 → SMTP openssl sclient(STARTTLS/TLS)
- 993/143 → IMAP openssl sclient(TLS/STARTTLS)
- 41641 → UDP nc -zu(Tailscale WireGuard)
- 22 → TCP nc -z(SSH)
- 其他 → TCP nc -z(通用回退)
每次检查都使用硬性timeout 5s包装器(在操作系统级别强制执行,不仅仅是套接字超时)。在--apply和--canary后自动调用。可独立使用进行按需验证。需要:curl、openssl、nc (netcat-openbsd)。
8) 插件完整性哈希(v1.3.0)
bash
快照当前插件哈希
bash scripts/plugin-integrity.sh --snapshot
对照存储的哈希验证插件完整性
bash scripts/plugin-integrity.sh --verify
对照hardening.json白名单检查插件
bash scripts/plugin-integrity.sh --drift
组合检查
bash scripts/plugin-integrity.sh --verify --drift
通过对每个插件的JS入口点(dist/index.js → index.js → *.js回退)进行SHA-256哈希处理,监控插件文件完整性。检测未经授权的修改、新增/删除的插件以及与hardening.json白名单的偏差。
9) 动态白名单(最用户友好的API)
要打开新端口或安全地添加服务(例如自定义电子邮件、视频提取、新的AI代理),
请勿编辑bash脚本或硬编码数组。始终使用动态配置辅助命令:
bash
bash scripts/whitelist.sh <域名> <端口>
(示例:bash whitelist.sh youtu.be 443)。这会自动将域名干净地注入到config/providers.txt引擎中,触发事务性配置刷新,并立即将更改应用到UFW。
10) 发布门控(v1.3.0)
bash
bash scripts/release-gate.sh
门控检查(必须全部通过):
- - 对技能结构运行quickvalidate.py
- 对所有shell脚本运行shellcheck(如果缺少则失败并显示安装提示)
- 将packageskill.py打包到skills/dist/clawd-zero-trust.skill
- --verify端点检查
版本化防火墙配置文件状态
状态文件(位于.state/中):
| 文件 | 用途 |
|---|
| egress-profile.json | 脚本哈希、版本、上次应用结果 |
| applied-ips.json |
用于--refresh增量的每个域名的IP快照 |
| plugin-hashes.json | 用于插件完整性验证的SHA-256哈希 |
在应用/金丝雀模式下,除非提供--force参数,否则哈希不匹配将被拒绝。whitelist.sh辅助工具无缝处理哈希不匹配问题。
参考资料
- - references/zero-trust-principles.md — AI代理的详细零信任框架
- references/false-positives.md — 已验证的触发审计警告的安全模式
硬性要求:禁止自我更新
未经创始人明确批准,切勿运行openclaw update、openclaw upgrade、npm install -