Back to skill

Security audit

OpenClaw Guardian CN

Security checks for vulnerabilities and agentic risk

Overview

This OpenClaw guardian skill is related to system monitoring, but it can automatically install persistent watchdog jobs and restart services without clear user opt-in.

Install only if you intentionally want a persistent OpenClaw watchdog. Before using it, review every cron or Scheduled Task entry it will add, avoid RunLevel Highest unless required, remove or replace the eval example, move state files out of /tmp, and make sure you have a clear command to disable the watchdog.

Vulnerability Patterns
  • System PersistenceInstalls backdoors, hooks, services, or scheduled tasks that survive the run
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (3)

T06 · System Persistence

Error
Location
SKILL.md:154
Finding

Automatic Installation of Persistent Gateway Watchdogs

Content
View full analysis
/dev/null | grep -q "openclaw-gateway"; then (crontab -l 2>/dev/null; echo "*/5 * * * * pgrep -f \"openclaw-gateway\" > /dev/null || cd $OPENCLAW_PATH && node ./dist/daemon-cli.js start >> /tmp/gateway_guardian.log 2>&1") | crontab - echo "✅ 已自动配置外部守护(每 5 分钟检查)" else echo "✅ 外部守护已配置" fi ``` The Windows instructions additionally recommend elevated scheduled-task registration: ```powershell $action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -File C:\Users\你的用户名\.openclaw\scripts\guardian-windows.ps1" $trigger = New-ScheduledTaskTrigger -At Startup Register-ScheduledTask -TaskName "OpenClaw Guardian" -Trigger $trigger -Action $action -RunLevel Highest ``` ### Technical Analysis The Skill directs the agent to modify the user's crontab automatically during the first self-check. The resulting task executes every five minutes and survives both the Skill invocation and future login sessions. The Windows alternative creates startup or repeating scheduled tasks and explicitly requests the highest available run level. A persistent watchdog is related to the declared guardian functionality, but automatic registration during an ordinary health check exceeds the minimum privileges required to inspect or restart the Gateway once. Persistence installation should be a separate, explicitly authorized operation. The elevated Windows run level is especially unnecessary unless a documented Gateway deployment requires administrator-only resources. The Linux command also depends on a mutable installation director ...[truncated 1622 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:60
Finding

Arbitrary Shell Command Execution Through eval

Content
View full analysis
/dev/null; then echo "✅ 自救成功" return 0 else echo "❌ 自救失败,需要手动处理" return 1 fi } ``` ### Technical Analysis `eval` reparses its argument as shell source code. Quoting `"$action"` when passing it to `eval` does not make the operation safe because metacharacters, substitutions, redirections, and command separators contained in the value are interpreted during the second parsing pass. The current document presents this as a recovery-function example rather than code invoked directly by the shipped shell scripts. However, an agent or user implementing the documented example could pass dynamically generated or untrusted recovery text into the function. A malicious value can append unrelated commands using constructs such as `;`, `&&`, command substitution, or output redirection. Process verification after execution does not constrain what the evaluated command can do and cannot detect unrelated commands executed alongside a legitimate Gateway action. ### Attack Path 1. The documented recovery function is adopted or executed as part of an automated recovery workflow. 2. A recovery action is built from untrusted, externally influenced, or insufficiently validated text. 3. The action is supplied as the first argument to `try_recover`. 4. `eval "$action"` reparses the text as shell syntax. 5. Embedded shell operators execute attacker-selected commands. 6. Those commands run with the permissions of the user or service executing the recovery workflow. ### Impact Assessment Successful exploitation permits arbitrary local command execution with the recovery process's privileges. ...[truncated 335 chars]
Remediation
View remediation
&2 return 2 ;; esac } ``` 3. Where arguments are required, pass them through shell arrays rather than constructing command strings. 4. Validate all action names and parameters against strict allowlists. 5. Do not accept raw recovery commands from user messages, configuration text, logs, process output, or remote content. 6. Execute recovery under a dedicated, non-administrative account with access only to the Gateway resources it needs. 7. Preserve the post-action status check, but do not treat it as a security control against command injection. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/guardian-daily.sh:5
Finding

Predictable and Insecure Temporary State Files

Content
View full analysis
"$SKILLS_YESTERDAY_FILE" # 5. 历史趋势(最近 7 天) REPORT+="----------------\n" REPORT+="📈 历史趋势 (最近 7 天):\n" if [ -f "$LOG_FILE" ]; then tail -7 "$LOG_FILE" | while read -r line; do REPORT+=" $line\n" done else REPORT+=" 暂无历史数据\n" fi # 判断状态 if echo "$REPORT" | grep -q "⚠️\|❌"; then REPORT+="----------------\n" REPORT+="状态: ⚠️ 需要关注\n" else REPORT+="----------------\n" REPORT+="状态: 正常 ✅\n" fi # 保存到历史记录 echo "$(date '+%m-%d') 内存:${MEM_PCT}% 磁盘:${DISK_USED}%" >> "$LOG_FILE" # 只保留最近 30 天 if [ -f "$LOG_FILE" ]; then tail -30 "$LOG_FILE" > "${LOG_FILE}.tmp" && mv "${LOG_FILE}.tmp" "$LOG_FILE" fi ``` ### Technical Analysis The script stores persistent state in globally predictable names under `/tmp`. On typical multi-user Unix systems, `/tmp` is writable by every local user. The script does not securely create these files, verify ownership, reject symbolic links, or set restrictive permissions. Shell redirection follows symbolic links. Consequently, an attacker who can create `/tmp/guardian_history.log`, `/tmp/guardian_history.log.tmp`, or `/tmp/guardian_skills_yesterday.txt` before the guardian runs may redirect writes to another file writable by the task account. An attacker can also prepopulate the files to falsify historical reports and skill-change comparisons. The risk is amplified if the script is launched by a privileged scheduler, although the supplied Linux examples normally install it in a user crontab. ### Attack Path 1. A lo ...[truncated 1110 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (29)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The code partially matches the declared purpose because it does check Gateway/process status and attempts a simple self-recovery by starting the Gateway if no process is found. However, several core advertised capabilities are absent from the supplied code: there is no mechanism for daily scheduled execution, no support for configuring check time, and no WebSocket or plugin health checks. Additionally, the script does extra filesystem inspection and baseline tracking of skills/extensions that are not mentioned in the description. Therefore the description materially overstates and misrepresents what this code chunk actually does.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared description promises an active guardian that both detects multiple kinds of anomalies and attempts automatic recovery/restart, with configurable daily scheduling. The provided code is only a reporting/check script: it inspects cron presence, process existence, memory/disk usage, and changes in skill directories, then writes simple history files under /tmp. There are no commands to restart services, recover processes, manage WebSocket connections, or configure cron timing. Additionally, its skill-directory diff/history behavior is not mentioned in the description. While part of the declared purpose—daily checking of Gateway status and some anomaly reporting—is represented, key promised capabilities are missing, making the description materially overstated relative to the actual code.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding

The code partially aligns with the declared recovery purpose because it checks for the gateway process and tries to restart it when absent. However, the declared description promises a broader guardian system with daily scheduled checks, customizable check times, and detection of process/WebSocket/plugin abnormalities. This code chunk implements only a narrow subset: a simple process-presence check plus restart attempt. That makes the description materially broader than the actual behavior represented by this code.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill describes automatically editing cron without a clear warning that it is installing persistent background execution. Silent or underexplained persistence is dangerous because users may not realize recurring commands are being added, and those commands can repeatedly launch processes and write logs indefinitely.

Content

No source excerpt is available for this finding.

YARA rule 'backdoor_persistence': Backdoor persistence with malicious payloads (shell commands, SSH key injection, hidden root users) [malware]

High
Category
YARA Match
Confidence
90% confidence
Finding

The YARA hit is broad, but in this case it matches a real persistence pattern: recurring cron installation that conditionally starts a daemon. While this is not overt malware, the same technique is commonly used for backdoor persistence, and in a skill context it is dangerous because it changes host behavior durably and automatically.

Content

Scanner excerpt · SKILL.md (reported line 167)May include surrounding context.

PE或[Environment]::OSVersion` 2. Linux → 检查 crontab 是否有守护 → 没有则添加 3. Windows → 检查任务计划程序是否有守护 → 没有则提示用户配置 4. 报告配置结果

bash
# 自动配置脚本
# 注意:以下路径假设 OpenClaw 安装在 ~/.openclaw 目录下
# 如果你的安装路径不同,请修改对应的路径
OPENCLAW_PATH=~/.openclaw
if ! crontab -l 2>/dev/null | grep -q "openclaw-gateway"; then
    (crontab -l 2>/dev/null; echo "*/5 * * * * pgrep -f \"openclaw-gateway\" > /dev/null || cd $OPENCLAW_PATH && node ./dist/daemon-cli.js start >> /tmp/gateway_guardian.log 2>&1") | crontab -
    echo "✅ 已自动配置外部守护(每 5 分钟检查)"
else
    echo "✅ 外部守护已配置"
fi

自救操作

当检测到异常时:

  1. 先尝试自动恢复
  2. 记录操作日志
  3. 报告恢复结果
  4. 必须验证自救是否成功(见上文"自救验证流程")

输出格式

自检完成后,报告格�

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The Windows flow registers a Scheduled Task, potentially with '-RunLevel Highest', without a strong warning about persistence and elevated execution. This creates a durable launch mechanism that may run with higher privileges, making accidental or malicious misuse significantly more impactful.

Content

No source excerpt is available for this finding.

YARA rule 'backdoor_persistence': Backdoor persistence with malicious payloads (shell commands, SSH key injection, hidden root users) [malware]

High
Category
YARA Match
Confidence
75% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

Scanner excerpt · scripts/guardian-daily.sh (reported line 15)May include surrounding context.

sh
#!/bin/bash

# OpenClaw 每日自检脚本 v2
# 支持:历史记录 + 预警机制

LOG_FILE="/tmp/guardian_history.log"
THRESHOLD_MEM=80
THRESHOLD_DISK=80

REPORT="🛡️ OpenClaw 每日自检\n"
REPORT+="时间: $(date '+%Y-%m-%d %H:%M')\n"
REPORT+="----------------\n"

# 1. 外部守护
if crontab -l 2>/dev/null | grep -q "openclaw-gateway"; then
    REPORT+="✅ Cron 守护: 已配置\n"
else
    REPORT+="❌ Cron 守护: 未配置\n"
fi

# 2. Gateway 进程
if pgrep -f "openclaw-gateway" > /dev/null; then
    REPORT+="✅ Gateway: 运行中\n"
else
    REPORT+="❌ Gateway: 已停止\n"
fi

# 3. 系统资源 + 预警
# 系统输出中文,需要转换
MEM_TOTAL=$(free | grep "内存:" | awk '{print $2}')
MEM_USED=$(free | grep "内存:" | awk '{print $3}')
if [ -n "$MEM_TOTAL" ] && [ "$MEM_TOTAL" -gt 0 ]; then
    MEM_PCT=$((MEM_USED * 100 / MEM_TOTAL))
else
    MEM_PCT=0

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger phrases are broad enough to match ordinary support or maintenance requests, increasing the chance the skill activates in contexts where the user did not intend persistent system changes or restart behavior. In a skill that can modify cron/tasks and restart services, overbroad activation meaningfully raises risk.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

Examples like '运行自检' or '检查系统状态' are generic and likely to overlap with normal diagnostic requests. Because the skill also describes auto-recovery and persistence setup, vague invocations could lead to unexpectedly invasive actions.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill instructs automatic creation of OS-level persistent jobs via cron or Scheduled Tasks on first use. Persistence mechanisms materially expand blast radius because they survive the current session, can repeatedly execute recovery commands, and alter host state beyond what users may expect from a 'self-check' skill.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
98% confidence
Finding

This command checks for and installs a cron-based watchdog that persists across sessions. Persistent recurring execution is sensitive because it can repeatedly start services, mask failures, and remain active after the user forgets it was installed.

Content

Scanner excerpt · SKILL.md (reported line 167)May include surrounding context.

md
# 注意:以下路径假设 OpenClaw 安装在 ~/.openclaw 目录下
# 如果你的安装路径不同,请修改对应的路径
OPENCLAW_PATH=~/.openclaw
if ! crontab -l 2>/dev/null | grep -q "openclaw-gateway"; then
    (crontab -l 2>/dev/null; echo "*/5 * * * * pgrep -f \"openclaw-gateway\" > /dev/null || cd $OPENCLAW_PATH && node ./dist/daemon-cli.js start >> /tmp/gateway_guardian.log 2>&1") | crontab -
    echo "✅ 已自动配置外部守护(每 5 分钟检查)"
else

Session Persistence

Medium
Category
Rogue Agent
Confidence
98% confidence
Finding

This line appends a recurring cron job that launches a daemon when a process check fails, creating session-independent persistence. Such mechanisms are commonly abused because they provide durable re-execution with minimal user visibility.

Content

Scanner excerpt · SKILL.md (reported line 168)May include surrounding context.

md
# 如果你的安装路径不同,请修改对应的路径
OPENCLAW_PATH=~/.openclaw
if ! crontab -l 2>/dev/null | grep -q "openclaw-gateway"; then
    (crontab -l 2>/dev/null; echo "*/5 * * * * pgrep -f \"openclaw-gateway\" > /dev/null || cd $OPENCLAW_PATH && node ./dist/daemon-cli.js start >> /tmp/gateway_guardian.log 2>&1") | crontab -
    echo "✅ 已自动配置外部守护(每 5 分钟检查)"
else
    echo "✅ 外部守护已配置"

Session Persistence

Medium
Category
Rogue Agent
Confidence
96% confidence
Finding

Although this line is only checking for an existing cron guard, it is part of a persistence-setup workflow and normalizes managing recurring jobs. In context, it supports installing durable execution and should be treated as part of a potentially risky persistence design.

Content

Scanner excerpt · SKILL.md (reported line 246)May include surrounding context.

bash
# 检查是否已有守护
crontab -l | grep "openclaw-gateway"

# 如果没有,自动添加(路径需要根据实际安装位置修改)
# 假设 OpenClaw 安装在 ~/.openclaw

Session Persistence

Medium
Category
Rogue Agent
Confidence
98% confidence
Finding

This command installs a cron watchdog that restarts the gateway automatically, establishing persistence beyond the current agent session. Repeated unattended process launching can hide problems, conflict with operator intent, and provide a durable foothold if the surrounding path or script is modified.

Content

Scanner excerpt · SKILL.md (reported line 250)May include surrounding context.

如果没有,自动添加(路径需要根据实际安装位置修改)

假设 OpenClaw 安装在 ~/.openclaw

(crontab -l 2>/dev/null; echo '*/5 * * * * pgrep -f "openclaw-gateway" > /dev/null || cd ~/.openclaw && node ./dist/daemon-cli.js start >> /tmp/gateway_guardian.log 2>&1') | crontab -

text

### 守护逻辑

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 265)May include surrounding context.

md
### 优势

- 不需要 sudo 权限
- 不依赖 Agent 本身
- 系统级守护,Gateway 挂了也能救

Session Persistence

Medium
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · SKILL.md (reported line 274)May include surrounding context.

如果需要修改检查间隔:

bash
crontab -e

# 每 3 分钟检查一次
*/3 * * * * pgrep -f "openclaw-gateway" > /dev/null || /path/to/start_gateway.sh

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The one-click setup section prescribes copying scripts into user directories and registering recurring external jobs, which establishes durable execution outside the agent runtime. Even if intended for resilience, this is a persistence pattern that can be abused or misapplied and should be treated as sensitive system modification.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
90% confidence
Finding

Copying scripts into a hidden application directory is not persistence by itself, but in this context it stages artifacts for subsequent recurring execution. Hidden/background operational files combined with scheduled jobs reduce visibility and increase the chance of unnoticed long-term behavior.

Content

Scanner excerpt · SKILL.md (reported line 339)May include surrounding context.

bash
# 复制脚本到 ~/.openclaw/
mkdir -p ~/.openclaw
cp -r /path/to/openclaw-guardian/scripts/guardian-daily.sh ~/.openclaw/

# 添加 cron 任务(路径根据实际安装位置修改)

Session Persistence

Medium
Category
Rogue Agent
Confidence
97% confidence
Finding

The one-click Linux setup adds a recurring cron watchdog, which is a clear persistence mechanism. Because it is framed as first-use setup, users may enable lasting autonomous execution without fully understanding the change.

Content

Scanner excerpt · SKILL.md (reported line 343)May include surrounding context.

md
cp -r /path/to/openclaw-guardian/scripts/guardian-daily.sh ~/.openclaw/

# 添加 cron 任务(路径根据实际安装位置修改)
(crontab -l 2>/dev/null; echo '*/5 * * * * pgrep -f "openclaw-gateway" > /dev/null || cd ~/.openclaw && node ./dist/daemon-cli.js start >> /tmp/gateway_guardian.log 2>&1') | crontab -

# 添加每日报告任务
(crontab -l 2>/dev/null; echo '0 9 * * * ~/.openclaw/guardian-daily.sh >> /tmp/daily_report.txt 2>&1') | crontab -

Session Persistence

Medium
Category
Rogue Agent
Confidence
97% confidence
Finding

This line adds a daily recurring report task, which is also session persistence even if less severe than auto-restart. Persistent scheduled execution still changes system behavior over time and may create unnoticed artifacts such as logs or reports.

Content

Scanner excerpt · SKILL.md (reported line 346)May include surrounding context.

(crontab -l 2>/dev/null; echo '*/5 * * * * pgrep -f "openclaw-gateway" > /dev/null || cd ~/.openclaw && node ./dist/daemon-cli.js start >> /tmp/gateway_guardian.log 2>&1') | crontab -

添加每日报告任务

(crontab -l 2>/dev/null; echo '0 9 * * * ~/.openclaw/guardian-daily.sh >> /tmp/daily_report.txt 2>&1') | crontab -

text

### Windows

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

User-facing comments and output strings throughout the script are in Chinese, and the file header explicitly labels it as such. There is no opt-in, fallback, or documented justification for restricting the skill's language/locale, which can violate language-choice policy.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · scripts/guardian-daily.sh (reported line 15)May include surrounding context.

sh
REPORT+="----------------\n"

# 1. 外部守护
if crontab -l 2>/dev/null | grep -q "openclaw-gateway"; then
    REPORT+="✅ Cron 守护: 已配置\n"
else
    REPORT+="❌ Cron 守护: 未配置\n"

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The comment "系统输出中文,需要转换" indicates the script assumes a Chinese-localized environment for parsing system command output. This is a locale-specific expectation presented without opt-in or documented justification, which can violate language/locale policy requirements.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The script automatically restarts the openclaw gateway process when it is missing, without any user confirmation, rate limiting, or safety checks. In a system-guardian skill this behavior is expected, but it is still risky because an unstable or compromised service could be repeatedly restarted, masking failures, interfering with incident response, or creating a restart loop.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
72% confidence
Finding

The log function at L013 appends output to a persistent log file, and logging begins at L016. While the code comments describe the script generally, there is no explicit user-facing warning that execution will write logs to a file in the user's home directory.

Content

No source excerpt is available for this finding.