Crusty Security — Security & Threat Scanning
Overview
Crusty Security protects OpenClaw agents against real threats: malware in downloaded files, compromised skills from ClawHub, data exfiltration, prompt injection payloads, and host-level compromise. It uses ClamAV for file scanning and AI-agent-specific static analysis.
Threat model: The agent itself is the attack surface. Prompt injection can lead to code execution. Malicious skills run with agent privileges. Crusty Security protects both the host AND the agent's integrity.
Quick Reference
| Task | Command |
|---|
| Install ClamAV | INLINECODE0 |
| Scan a file |
bash scripts/scan_file.sh /path/to/file |
| Scan a directory |
bash scripts/scan_file.sh -r /path/to/dir |
| Audit a skill |
bash scripts/audit_skill.sh /path/to/skill/ |
| Host security audit |
bash scripts/host_audit.sh |
| Monitor agent integrity |
bash scripts/monitor_agent.sh |
| Generate security report |
bash scripts/generate_report.sh |
All scripts output JSON. All scripts support --help. All paths are relative to this skill directory.
Setup (First Run)
Run bash setup.sh — that's it. This will:
- 1. Install ClamAV if missing
- Configure freshclam (macOS Homebrew fix)
- Send initial heartbeat to dashboard (if
CRUSTY_API_KEY set) - Run initial host audit + workspace scan (populates dashboard immediately)
- Check which scheduled scans need to be created
⚠️ IMPORTANT — After setup.sh, you MUST create the cron jobs below using the OpenClaw cron tool. Setup.sh handles the bash-level installation, but cron jobs require agent-level tools. Do this immediately after first install — don't wait for the user to ask.
Required Cron Jobs (create on first install)
Check what's missing: INLINECODE10
Use the OpenClaw cron tool (cron add) to create these. Replace {SKILL_DIR} with the actual path to this skill directory and {WORKSPACE} with the workspace path (usually /data/workspace).
| Name | Schedule | sessionTarget | Payload |
|---|
| INLINECODE15 | cron INLINECODE16 | main / systemEvent | INLINECODE17 |
| INLINECODE18 |
cron
0 3 * * 0 | main / systemEvent |
Run Crusty Security weekly scan: bash {SKILL_DIR}/scripts/scan_file.sh -r {WORKSPACE} && bash {SKILL_DIR}/scripts/host_audit.sh && bash {SKILL_DIR}/scripts/generate_report.sh --output /tmp/crusty_logs/weekly_report.md |
|
crusty-monthly-deep | cron
0 4 1 * * | main / systemEvent |
Run Crusty Security monthly deep audit: bash {SKILL_DIR}/scripts/host_audit.sh --deep |
Dashboard Cron Jobs (only if CRUSTY_API_KEY is set)
| Name | Schedule | sessionTarget | Payload |
|---|
| INLINECODE25 | every 300000ms (5 min) | main / systemEvent | INLINECODE26 |
| INLINECODE27 |
every 43200000ms (12h) | isolated / agentTurn |
Run ClawHub security sync: python3 {SKILL_DIR}/scripts/clawhub_sync.py --push. Report any critical or high severity findings. |
Check cron list first — skip any that already exist (match by name prefix crusty-).
See references/setup.md for detailed configuration.
Dashboard Connection
If your human has configured CRUSTY_API_KEY, the skill sends scan results to the Crusty Security dashboard (crustysecurity.com):
- - Heartbeats are sent every 5 minutes automatically — keeps the dashboard showing agent status
- Scan results are pushed when you add
--push to scan commands - ClawHub sync sends skill inventory with INLINECODE34
- If
CRUSTY_API_KEY is NOT set, everything works locally — no data is sent anywhere - The dashboard never connects TO the agent — data flows one way (agent → dashboard)
Scanning Workflows
File Scanning
Triggers: "scan this file", "is this safe", "check this download", "virus scan"
- 1. Run
bash scripts/scan_file.sh <path> for ClamAV local scan - Report results:
- ✅ Clean — "No threats detected. Scanned with ClamAV, signatures from [date]."
- ⚠️ Suspicious — "Low-confidence detection by ClamAV. Recommend quarantine for review."
- 🚨 Malicious — "Threat detected: [name]. Recommend quarantine. Options: quarantine, delete, or ignore."
For directories:
CODEBLOCK0
Quarantine workflow:
CODEBLOCK1
Important notes:
- - ClamAV prefers clamdscan (daemon) when available, falls back to clamscan
- Max file size default: 200M (configurable via
CRUSTY_MAX_FILE_SIZE) - Encrypted archives: flagged as "unscanned" — cannot inspect contents
- Large archives: ClamAV handles zip, rar, 7z, tar, gz natively
Skill Auditing (Supply Chain Security)
Triggers: "audit this skill", "is this skill safe", "check skill security", "scan skill"
INLINECODE38
What it checks:
- - 🔴 Critical: curl/wget piped to shell, reverse shell patterns, crypto mining indicators
- 🟠 High: eval/exec with dynamic input, base64 decode patterns, data exfiltration endpoints (webhook.site, ngrok, etc.), credential harvesting, binary executables, agent config modification
- 🟡 Medium: hidden files, system file access, hardcoded IPs, obfuscated code, persistence mechanisms (cron, systemd)
- 🔵 Low/Info: large skill size, credential references in docs
Output: Risk score (low/medium/high/critical) + detailed findings with evidence.
When to use:
- - Before installing any skill from ClawHub
- When reviewing third-party skill contributions
- Periodically on all installed skills: INLINECODE39
Host Security Audit
Triggers: "audit host", "security audit", "check host security"
INLINECODE40 or INLINECODE41
Checks:
- - Suspicious cron jobs (curl piping, base64, reverse shells)
- Unexpected listening ports
- Recently modified system files (deep mode)
- SSH key audit (excessive keys, no-comment keys, root login)
- Sensitive file permissions (world-writable /etc/passwd, etc.)
- ClamAV signature freshness
- INLINECODE42 (if available)
Output: Posture score (0-100) + findings. Score deductions: critical (-25), high (-15), medium (-10), low (-5).
Agent Behavior Monitoring
Triggers: "check agent integrity", "monitor agent", "is the agent compromised"
INLINECODE43
What it checks:
- - Recent modifications to AGENTS.md, SOUL.md, MEMORY.md, TOOLS.md, USER.md
- Memory file churn (>10 files modified = suspicious)
- Unexpected cron jobs (anything not clawguard/freshclam/standard maintenance)
- Suspicious outbound connections (IRC ports, backdoor ports, Tor)
- Files created outside workspace (/tmp executables, home directory changes)
- Suspicious processes (xmrig, nc -l, ncat, socat, chisel)
- High CPU processes (>80% — potential miners)
- Sensitive file exposure (.env files, world-readable SSH keys)
Output: Status (healthy / warningspresent / compromisedindicators) + findings.
Security Report Generation
Triggers: "security report", "threat report", "posture report"
INLINECODE44 or INLINECODE45
Compiles all recent scan results into a markdown security posture report with:
- - Scan summary (total, clean, threats, errors)
- Threat details with file paths and actions taken
- Security posture score with emoji indicators
- Recommendations (missing tools, scan schedules)
Automatic Scheduled Scanning
Cron jobs are defined in the Setup (First Run) section above. Create them immediately on first install using the OpenClaw cron tool.
To verify all crons are configured: INLINECODE46
False Positive Handling
ClamAV has moderate false positive rates. Strategy:
- 1. Single ClamAV detection, known safe source → Likely false positive. Log and skip.
- ClamAV detection, unknown source → Quarantine and investigate.
- ClamAV detection + skill audit findings → Real threat. Quarantine immediately.
To handle a false positive:
- - Submit to ClamAV: https://www.clamav.net/reports/fp
- Document in scan logs for future reference
Quarantine Procedures
Location: $CRUSTY_QUARANTINE (default: /tmp/crusty_quarantine)
Manifest: manifest.json in quarantine directory tracks original paths and timestamps.
CODEBLOCK2
Never use clamscan --remove. Always quarantine first, verify, then delete.
Offline Mode
Crusty Security works fully offline with reduced capability:
- - ✅ ClamAV scanning (local signatures)
- ✅ Skill auditing (static analysis, no network needed)
- ✅ Host auditing (local checks)
- ✅ Agent monitoring (local checks)
- ⚠️ ClamAV signatures may be stale (check freshness in host audit)
Resource-Constrained Environments (Raspberry Pi)
For hosts with <2GB RAM:
- -
install_clamav.sh auto-detects low RAM and skips daemon mode - Use
clamscan (on-demand) instead of clamd (daemon) - Use incremental scanning (
--incremental) to reduce scan time - Skill auditing and agent monitoring have minimal resource requirements
For hosts with <1GB RAM:
- - Consider skipping ClamAV entirely
- Use skill auditing + agent monitoring only
- These tools are shell/Python with negligible memory usage
Environment Variables
| Variable | Default | Description |
|---|
| INLINECODE55 | (none) | Dashboard API key (cg_live_...) |
| INLINECODE57 |
https://crustysecurity.com | Dashboard URL |
|
CRUSTY_QUARANTINE |
/tmp/crusty_quarantine | Quarantine directory |
|
CRUSTY_LOG_DIR |
/tmp/crusty_logs | Scan log directory |
|
CRUSTY_MAX_FILE_SIZE |
200M | Max file size to scan |
|
CRUSTY_WORKSPACE | auto-detected | Agent workspace path |
Backwards compat: CLAWGUARD_* env vars are still supported but deprecated. Use CRUSTY_* going forward.
Incident Response
When a real threat is confirmed, see references/remediation.md for the full checklist. Quick summary:
- 1. Quarantine the file immediately
- Assess scope — was it executed? Did it modify other files?
- Check persistence — cron jobs, SSH keys, shell profiles, systemd services
- Check exfiltration — outbound connections, DNS queries, API key usage
- Rotate credentials if any were potentially exposed
- Full scan — INLINECODE69
- Document the incident
Crusty Security — 安全与威胁扫描
概述
Crusty Security 保护 OpenClaw 代理免受真实威胁:下载文件中的恶意软件、来自 ClawHub 的受损技能、数据泄露、提示注入载荷以及主机级入侵。它使用 ClamAV 进行文件扫描,并执行针对 AI 代理的静态分析。
威胁模型: 代理本身即为攻击面。提示注入可能导致代码执行。恶意技能以代理权限运行。Crusty Security 同时保护主机和代理的完整性。
快速参考
| 任务 | 命令 |
|---|
| 安装 ClamAV | bash scripts/installclamav.sh |
| 扫描文件 |
bash scripts/scanfile.sh /path/to/file |
| 扫描目录 | bash scripts/scan_file.sh -r /path/to/dir |
| 审计技能 | bash scripts/audit_skill.sh /path/to/skill/ |
| 主机安全审计 | bash scripts/host_audit.sh |
| 监控代理完整性 | bash scripts/monitor_agent.sh |
| 生成安全报告 | bash scripts/generate_report.sh |
所有脚本输出 JSON 格式。所有脚本支持 --help。所有路径均相对于此技能目录。
设置(首次运行)
运行 bash setup.sh 即可。此操作将:
- 1. 安装 ClamAV(如果缺失)
- 配置 freshclam(macOS Homebrew 修复)
- 向仪表板发送初始心跳(如果设置了 CRUSTYAPIKEY)
- 运行初始主机审计 + 工作区扫描(立即填充仪表板)
- 检查需要创建的定时扫描任务
⚠️ 重要提示 — 运行 setup.sh 后,您必须使用 OpenClaw 定时任务工具创建以下 cron 任务。 Setup.sh 处理 bash 级别的安装,但 cron 任务需要代理级别的工具。首次安装后立即执行此操作 — 不要等待用户提出要求。
必需的 Cron 任务(首次安装时创建)
检查缺失项:bash scripts/check_crons.sh
使用 OpenClaw cron 工具(cron add)创建这些任务。将 {SKILL_DIR} 替换为此技能目录的实际路径,将 {WORKSPACE} 替换为工作区路径(通常为 /data/workspace)。
| 名称 | 调度 | sessionTarget | 载荷 |
|---|
| crusty-daily-scan | cron 0 3 | main / systemEvent | 运行 Crusty Security 每日扫描:bash {SKILLDIR}/scripts/scanfile.sh --incremental -r {WORKSPACE} && bash {SKILLDIR}/scripts/monitoragent.sh |
| crusty-weekly-full |
cron 0 3 * 0 | main / systemEvent | 运行 Crusty Security 每周扫描:bash {SKILL
DIR}/scripts/scanfile.sh -r {WORKSPACE} && bash {SKILL
DIR}/scripts/hostaudit.sh && bash {SKILL
DIR}/scripts/generatereport.sh --output /tmp/crusty
logs/weeklyreport.md |
| crusty-monthly-deep | cron 0 4 1
| main / systemEvent | 运行 Crusty Security 每月深度审计:bash {SKILL
DIR}/scripts/hostaudit.sh --deep |
仪表板 Cron 任务(仅当设置了 CRUSTYAPIKEY 时)
| 名称 | 调度 | sessionTarget | 载荷 |
|---|
| crusty-heartbeat | 每 300000 毫秒(5 分钟) | main / systemEvent | Crusty Security 心跳:运行 bash {SKILLDIR}/scripts/dashboard.sh heartbeat |
| crusty-clawhub-sync |
每 43200000 毫秒(12 小时) | isolated / agentTurn | 运行 ClawHub 安全同步:python3 {SKILLDIR}/scripts/clawhub_sync.py --push。报告任何严重或高严重性发现。 |
先检查 cron list — 跳过任何已存在的任务(按名称前缀 crusty- 匹配)。
详细配置请参见 references/setup.md。
仪表板连接
如果您的用户已配置 CRUSTYAPIKEY,该技能会将扫描结果发送到 Crusty Security 仪表板(crustysecurity.com):
- - 心跳每 5 分钟自动发送 — 保持仪表板显示代理状态
- 扫描结果在您向扫描命令添加 --push 时推送
- ClawHub 同步通过 python3 scripts/clawhubsync.py --push 发送技能清单
- 如果未设置 CRUSTYAPI_KEY,一切在本地运行 — 不会向任何地方发送数据
- 仪表板从不连接到代理 — 数据单向流动(代理 → 仪表板)
扫描工作流程
文件扫描
触发条件:扫描这个文件、这个安全吗、检查这个下载、病毒扫描
- 1. 运行 bash scripts/scan_file.sh 进行 ClamAV 本地扫描
- 报告结果:
- ✅ 干净 — 未检测到威胁。已使用 ClamAV 扫描,签名日期为 [日期]。
- ⚠️ 可疑 — ClamAV 低置信度检测。建议隔离以供审查。
- 🚨 恶意 — 检测到威胁:[名称]。建议隔离。选项:隔离、删除或忽略。
对于目录:
bash
bash scripts/scan_file.sh -r /data/workspace # 完整递归扫描
bash scripts/scan_file.sh -r --incremental /data/workspace # 跳过未更改文件
隔离工作流程:
bash
bash scripts/scan_file.sh --quarantine /path/to/file # 移动到隔离区
隔离位置:$CRUSTYQUARANTINE(默认:/tmp/crustyquarantine)
清单:/tmp/crusty_quarantine/manifest.json
重要说明:
- - ClamAV 优先使用 clamdscan(守护进程),回退到 clamscan
- 最大文件大小默认值:200M(可通过 CRUSTYMAXFILE_SIZE 配置)
- 加密归档:标记为未扫描 — 无法检查内容
- 大型归档:ClamAV 原生支持 zip、rar、7z、tar、gz
技能审计(供应链安全)
触发条件:审计这个技能、这个技能安全吗、检查技能安全、扫描技能
bash scripts/audit_skill.sh /path/to/skill/directory/
检查内容:
- - 🔴 严重: curl/wget 管道到 shell、反弹 shell 模式、加密货币挖矿指标
- 🟠 高: 使用动态输入的 eval/exec、base64 解码模式、数据泄露端点(webhook.site、ngrok 等)、凭据收集、二进制可执行文件、代理配置修改
- 🟡 中: 隐藏文件、系统文件访问、硬编码 IP、混淆代码、持久化机制(cron、systemd)
- 🔵 低/信息: 技能体积过大、文档中的凭据引用
输出: 风险评分(低/中/高/严重)+ 带有证据的详细发现。
使用时机:
- - 安装任何来自 ClawHub 的技能之前
- 审查第三方技能贡献时
- 定期对所有已安装技能执行:for d in /data/workspace/skills/*/; do bash scripts/audit_skill.sh $d; done
主机安全审计
触发条件:审计主机、安全审计、检查主机安全
bash scripts/hostaudit.sh 或 bash scripts/hostaudit.sh --deep
检查内容:
- - 可疑的 cron 任务(curl 管道、base64、反弹 shell)
- 意外的监听端口
- 最近修改的系统文件(深度模式)
- SSH 密钥审计(过多密钥、无注释密钥、root 登录)
- 敏感文件权限(全局可写的 /etc/passwd 等)
- ClamAV 签名新鲜度
- openclaw security audit(如果可用)
输出: 态势评分(0-100)+ 发现。评分扣减:严重(-25)、高(-15)、中(-10)、低(-5)。
代理行为监控
触发条件:检查代理完整性、监控代理、代理是否受损
bash scripts/monitor_agent.sh
检查内容:
- - AGENTS.md、SOUL.md、MEMORY.md、TOOLS.md、USER.md 的最近修改
- 内存文件频繁