Back to skill

Security audit

Openclaw Auto Recovery

Security checks for vulnerabilities and agentic risk

Overview

This is a real OpenClaw monitoring and auto-recovery skill, but it has high-impact persistent automation and unsafe configuration handling that can execute code from config values.

Only install this after reviewing the scripts and using a config file you fully trust. Treat config.env as executable code in this version, protect and rotate the Feishu and Gateway secrets, and expect the daemon to persistently restart Gateway, send alerts to Feishu, and overwrite OpenClaw config during recovery.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/heartbeat-daemon.sh:27
Finding

Arbitrary Shell Execution Through Daemon Configuration Loading

Content
View full analysis
&2 exit 1 fi } ``` ### Technical Analysis The daemon loads `config.env` with Bash's `source` command. A sourced file is not treated as passive key-value data; every shell construct in the file is executed in the daemon's current process. An attacker who can create, replace, or modify the selected configuration file can insert command substitutions, function calls, redirections, or arbitrary commands. The injected commands run whenever the heartbeat daemon starts or restarts. The `--config` option also permits an alternate file to be selected. Although choosing that file normally requires user action, presenting an untrusted file as a configuration file provides a direct code-execution path. `set -a` additionally exports all subsequently assigned configuration values to child processes. This unnecessarily exposes sensitive values such as `FEISHU_APP_SECRET` and `GATEWAY_TOKEN` to subprocess environments. ### Attack Path 1. An attacker supplies a malicious configuration file or gains write access to the configured `config.env`. 2. The attacker inserts shell code, for example: ```bash FEISHU_APP_ID="expected-value" arbitrary_command --attacker-controlled-arguments ``` 3. The user starts the daemon with `--config` or the enabled systemd service restarts automatically. 4. `load_config` executes `source "$config_file"`. 5. The injected command runs with the privileges and filesystem access of the user operating the daemon. 6. Because the service is configured to restart automatically, malicious code r ...[truncated 702 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/install-heartbeat.sh:72
Finding

Arbitrary Shell Execution Through Installer Configuration Loading

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/heartbeat-daemon.sh:41
Finding

JavaScript Injection Through Interpolation of Configuration Values into node -e Programs

Content
View full analysis
/dev/null } ``` ```bash check_gateway() { local ws_module="${WS_MODULE:-$(detect_ws_module)}" node -e " const WebSocket = require('${ws_module}'); const ws = new WebSocket('ws://127.0.0.1:${GATEWAY_PORT}', { headers: { 'Authorization': 'Bearer ${GATEWAY_TOKEN}' } }); ws.on('open', () => { console.log('UP'); ws.close(); process.exit(0); }); ws.on('error', () => { console.log('DOWN'); process.exit(0); }); setTimeout(() => { console.log('DOWN'); process.exit(1); }, 4000); " 2>/dev/null } ``` ### Technical Analysis The daemon constructs JavaScript source code by directly interpolating configuration values into a `node -e` command. The affected values include: - `OPENCLAW_JSON` - `WS_MODULE` - `GATEWAY_PORT` - `GATEWAY_TOKEN` These values are placed inside JavaScript string literals or expressions without JavaScript-safe encoding. A value containing a quote and additional JavaScript can terminate the intended literal and inject new statements. For example, a malicious `OPENCLAW_JSON` value can close the string passed to `readFileSync` and append Node.js code. Node.js code can invoke `child_process`, read files, write files, or execute operating-system commands. This issue is independently dangerous even if configuration loading is later changed from `source` to a safe parser. Treating a value as data at the shell layer does not make it safe to concatenate into JavaScript program text. ### Attack Path 1. An attacker controls or modifies one of the affected configuration values. 2. The attacker crafts the value to terminate its surrou ...[truncated 1243 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
Findings (21)

Chaining Abuse

High
Category
Tool Misuse
Confidence
91% confidence
Finding

The backup cleanup pipeline uses ls ... | tail ... | xargs rm -f, which is unsafe for filenames containing whitespace, newlines, glob surprises, or leading dashes. Because OPENCLAW_JSON comes from sourced configuration, an attacker or misconfiguration could influence backup paths and cause unintended file deletion during rotation.

Content

Scanner excerpt · scripts/heartbeat-daemon.sh (reported line 64)May include surrounding context.

sh
cp "$OPENCLAW_JSON" "$bak"
    log "CONFIG: 备份已创建 $bak"
    # 只保留最近5份
    ls -t "${OPENCLAW_JSON}.auto."* 2>/dev/null | tail -n +6 | xargs rm -f 2>/dev/null
}

# 保存"最后一次已知良好"配置(最多3份,MD5 不重复才保存)

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · scripts/heartbeat-daemon.sh (reported line 173)May include surrounding context.

sh
echo "$(date '+%Y-%m-%d %H:%M:%S') $msg" >> "$ALERT_LOG"

    local token_resp
    token_resp=$(curl -s -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
        -H "Content-Type: application/json" \
        -d "{\"app_id\": \"${FEISHU_APP_ID}\", \"app_secret\": \"${FEISHU_APP_SECRET}\"}")

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · scripts/heartbeat-daemon.sh (reported line 192)May include surrounding context.

sh
fi

    local send_resp
    send_resp=$(curl -s -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" \
        -H "Authorization: Bearer $token" \
        -H "Content-Type: application/json" \
        -d "{\"receive_id\": \"${TARGET_OPEN_ID}\", \"msg_type\": \"text\", \"content\": \"{\\\"text\\\":\\\"${msg}\\\"}\"}")

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The installer loads the user-supplied or existing configuration with source, which executes arbitrary shell code in the current process rather than merely parsing key/value settings. In an installation script that later writes files and enables a persistent service, this creates a high-risk code execution path if the config file is malicious, tampered with, or comes from an untrusted location.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
95% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/uninstall-heartbeat.sh (reported line 31)May include surrounding context.

sh
if [[ "$confirm_config" =~ ^[Yy]$ ]]; then
    rm -rf "$CONFIG_DIR"
    echo "✅ 配置目录已删除"
    rm -f "${LOG_DIR}/heartbeat.log" "${LOG_DIR}/alerts.log" "${LOG_DIR}/restart-fail-count"
    echo "✅ 日志文件已删除"
fi

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The markdown explains that after failure the system will repeatedly perform a full cycle of overwriting configuration, restarting, waiting, and rechecking. Because this behavior is destructive to current config state and can repeatedly interrupt service, the documentation should explicitly warn users about the impact.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This markdown file states that the skill performs automatic restarts and configuration backup/rollback, which can affect service availability and overwrite live configuration. The release notes do not include any warning about these potentially disruptive behaviors or their operational impact on user systems.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill invokes shell-based installation, service management, log access, and uninstallation workflows but does not declare any explicit tool scope or permissions boundary. In an agent environment, this increases the chance that the skill can be invoked with broader-than-intended shell access, enabling filesystem changes, service manipulation, and exposure of sensitive local configuration without clear user consent boundaries.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger phrases include broad operational language such as '服务器告警', '自动重启', and '健康检查', which are common in normal admin conversations and may cause accidental invocation. Because this skill performs privileged shell-backed operational tasks, unintended activation could lead to service restarts, monitoring changes, or access to sensitive configuration context when the user only intended a discussion.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
65% 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 21)May include surrounding context.

md
- **Gateway 监控**:WebSocket 连通性检测,DOWN 时自动重启(最多连续 3 次)
- **主机资源**:磁盘 / 内存 / CPU / 进程监控,超阈值飞书告警
- **配置安全**:变更前自动备份,JSON 损坏时自动回滚
- **进程保活**:由 systemd 托管,崩溃自动重启,不依赖 nohup

## 快速开始

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The documentation explicitly instructs users to extract the Gateway token from a local config file but provides no warning that the value is a sensitive secret, no guidance on limiting exposure, and no caution against logging or pasting it into shared channels. In an infrastructure auto-recovery skill, this increases the chance of accidental credential disclosure, which could allow unauthorized access to the OpenClaw Gateway if the token is exposed.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script sends alert messages to Feishu over HTTPS and uses FEISHU_APP_ID, FEISHU_APP_SECRET, TARGET_OPEN_ID, and alert contents derived from system state. While this is part of alerting functionality, the script's visible usage/help text does not disclose that monitoring results and identifiers will be transmitted to an external service.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
76% confidence
Finding

The script transmits Feishu app credentials to an external API endpoint and does so from a continuously running daemon. While this is functionally required for token acquisition, it increases exposure of sensitive credentials and creates dependency on external network communication; compromise of configuration storage, logs, or a misdirected endpoint could leak secrets or enable unauthorized messaging.

Content

Scanner excerpt · scripts/heartbeat-daemon.sh (reported line 173)May include surrounding context.

sh
echo "$(date '+%Y-%m-%d %H:%M:%S') $msg" >> "$ALERT_LOG"

    local token_resp
    token_resp=$(curl -s -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
        -H "Content-Type: application/json" \
        -d "{\"app_id\": \"${FEISHU_APP_ID}\", \"app_secret\": \"${FEISHU_APP_SECRET}\"}")

External Transmission

Medium
Category
Data Exfiltration
Confidence
72% confidence
Finding

The script sends alert messages containing operational state to an external Feishu messaging API. In monitoring context this is expected, but it still creates a data exfiltration path if message contents include sensitive infrastructure details, and misuse of the token could allow unauthorized outbound notifications.

Content

Scanner excerpt · scripts/heartbeat-daemon.sh (reported line 192)May include surrounding context.

sh
fi

    local send_resp
    send_resp=$(curl -s -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" \
        -H "Authorization: Bearer $token" \
        -H "Content-Type: application/json" \
        -d "{\"receive_id\": \"${TARGET_OPEN_ID}\", \"msg_type\": \"text\", \"content\": \"{\\\"text\\\":\\\"${msg}\\\"}\"}")

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This shell script automatically backs up, overwrites, and rolls back the configured JSON file and restarts the openclaw-gateway service when health checks fail. Although actions are logged internally, there is no explicit user-facing warning in the script header/help text that running this daemon can change configuration files and restart services automatically.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script accepts --config and silently sources that file without warning the user that any shell code inside it will run. This materially increases the risk of social-engineering or accidental execution because users may reasonably assume they are supplying passive configuration data, not executable code.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The installer interactively collects sensitive values such as FEISHU_APP_SECRET and GATEWAY_TOKEN and persists them to disk, but it does not warn the user that these secrets will be stored in plaintext in a long-lived config file. In an infrastructure-monitoring skill, these credentials may grant message-sending or gateway control capability, so undisclosed persistent storage increases exposure if the account or host is later compromised.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

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

Content

Scanner excerpt · scripts/install-heartbeat.sh (reported line 181)May include surrounding context.

sh
# 写入配置文件
mkdir -p "$CONFIG_DIR"
generate_config_sample | sed "s|^WS_MODULE=.*|WS_MODULE=\"${WS_MODULE_PATH}\"|" > "$CONFIG_FILE"
chmod 600 "$CONFIG_FILE"
echo "✅ 配置文件已写入: $CONFIG_FILE"

# 写入 systemd service

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% 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/install-heartbeat.sh (reported line 185)May include surrounding context.

sh
echo "✅ 配置文件已写入: $CONFIG_FILE"

# 写入 systemd service
mkdir -p "$SYSTEMD_DIR"
cat > "$SERVICE_FILE" <<EOF
[Unit]
Description=Infra Heartbeat Daemon

Session Persistence

Medium
Category
Rogue Agent
Confidence
80% 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/install-heartbeat.sh (reported line 206)May include surrounding context.

sh
# 重载 systemd 并启用
systemctl --user daemon-reload
systemctl --user enable heartbeat-daemon.service
systemctl --user start heartbeat-daemon.service

echo ""

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

User-facing comments, help text, log messages, and alert content are written in Chinese throughout the script, with no option to select another language or locale. This imposes a fixed language behavior that may violate language-choice policy when used in broader environments.

Content

No source excerpt is available for this finding.