Back to skill

Security audit

OpenClaw Watchdog Li

Security checks for vulnerabilities and agentic risk

Overview

This watchdog is mostly coherent, but it can automatically make persistent host proxy changes and broad process restarts without enough user control.

Review carefully before installing. Run it only on a machine where automatic Gateway restarts and proxy changes are acceptable, avoid running it with sudo privileges, and prefer removing or disabling the host-wide proxy edits before enabling the systemd watchdog.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/watchdog.sh:173
Finding

Unreliable network checks trigger privileged and persistent proxy configuration changes

Content
View full analysis
/dev/null # 清除环境变量 systemctl --user set-environment http_proxy= https_proxy= all_proxy= HTTP_PROXY= HTTPS_PROXY= ALL_PROXY= 2>/dev/null # 注释掉 bashrc 中的代理配置 sed -i 's/^export \(http\|https\|all\)_proxy=/#DISABLED: export \1_proxy=/' ~/.bashrc 2>/dev/null touch "$PROXY_DISABLED_FILE" log "✅ 代理已禁用" } ``` This function is reached after both network probes fail: ```bash check_network() { ping -c 1 -W 3 www.baidu.com > /dev/null 2>&1 && return 0 ping -c 1 -W 3 223.5.5.5 > /dev/null 2>&1 && return 0 return 1 } ``` ### Technical Analysis The watchdog treats failure to ping two hard-coded external targets as proof that the system proxy is faulty. It then performs configuration changes substantially broader than the legitimate requirement of monitoring and restarting the Gateway: - It invokes `sudo` to rename `/etc/profile.d/proxy.sh`, affecting system-wide shell configuration. - It clears proxy variables from the systemd user-manager environment. - It rewrites the user's `~/.bashrc`. - It creates a marker that prevents later attempts to restore or reevaluate the disabled proxy. - It provides no backup, rollback, locking, or validation that the proxy caused the failure. ICMP probes can fail because of packet filtering, DNS failure, endpoint unavailability, routing policy, captive portals, or deliberate network interference. Such failures do not establish that disabling the proxy is appropriate. The `sudo` command does not itself bypass sudo policy. However, if the account has passwordless or cached sudo authoriz ...[truncated 1574 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/watchdog.sh:194
Finding

Predictable shared temporary files allow symlink and watchdog-state manipulation

Content
View full analysis
"$COUNT_FILE" echo $now > "$TIME_FILE" return 0 fi [ -f "$COUNT_FILE" ] && count=$(cat "$COUNT_FILE") count=$((count + 1)) echo $count > "$COUNT_FILE" echo $now > "$TIME_FILE" if [ $count -gt $MAX_RESTARTS ]; then log "❌ 已重启 ${count} 次仍异常,停止自动重启(窗口:${RESTART_WINDOW}s)" return 1 fi log "⚠️ 重启尝试 ${count}/${MAX_RESTARTS}" return 0 } ``` The Gateway output also uses another predictable `/tmp` path: ```bash openclaw gateway start > /tmp/openclaw_gateway.log 2>&1 & ``` ### Technical Analysis The script stores trusted state and output in predictable paths under the shared `/tmp` namespace. It does not: - Create a private runtime directory. - Set a restrictive `umask`. - Create files exclusively. - Reject symbolic links. - Verify file ownership or mode. - Lock files against concurrent modification. - Validate that counter contents are strictly numeric before arithmetic evaluation. Shell output redirection follows symbolic links. A local attacker who can ...[truncated 2041 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/watchdog.sh:222
Finding

Broad command-line process matching can terminate unrelated processes

Content
View full analysis
/dev/null sleep 3 # 启动新进程(清除代理环境变量) nohup env -u http_proxy -u https_proxy -u all_proxy \ -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY \ openclaw gateway start > /tmp/openclaw_gateway.log 2>&1 & local new_pid=$! echo $new_pid > "$PID_FILE" log "启动完成,PID: $new_pid" sleep 10 if is_process_alive; then log "✅ Gateway 启动成功" else log "❌ Gateway 启动失败" fi } ``` ### Technical Analysis `pkill -f` matches a regular expression against each process's complete command line. The termination operation is not restricted to: - The systemd unit that was checked earlier. - The PID stored in `PID_FILE`. - A validated executable path. - A process start time or owner-specific service identity. Consequently, any process visible and signalable by the watchdog account whose full command line contains `openclaw-gateway` can be terminated. The process does not need to be the Gateway instance that the watchdog intended to restart. The same script writes a PID file when starting the replacement process but does not use that PID to target the old process safely. It also does not validate that the background PID still represents the expected executable before trusting it. ### Attack Path 1. An unrelated process running under the same user has `openclaw-gateway` in its command-line arguments, executable invocation, or wrapper command. 2. The watchdog detects Gateway unavailability or a qualifying WebSocket error. 3. `can_restart` permits recovery and `restart_gateway` executes. 4. `pkill -f "openclaw-gateway"` matches both the intended Gateway and the unrelated process. 5. Every matching process that the watchdog user can ...[truncated 828 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (9)

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The watchdog goes beyond monitoring and bounded restart behavior by persistently changing host proxy configuration under network-failure conditions. Because it edits system/user settings and clears environment variables, a transient application issue can cause unintended host-wide network policy changes that affect other processes and security controls.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The script modifies persistent shell and system proxy settings by moving /etc/profile.d/proxy.sh, clearing user systemd proxy environment, and rewriting ~/.bashrc. This is dangerous because a watchdog for one service should not silently alter broader host networking configuration, which can break connectivity, bypass enterprise routing requirements, or disable security monitoring that depends on proxies.

Content

No source excerpt is available for this finding.

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · scripts/watchdog.sh (reported line 174)May include surrounding context.

sh
log "⚠️ 网络异常,关闭系统代理..."

    # 禁用系统代理
    [ -f /etc/profile.d/proxy.sh ] && sudo mv /etc/profile.d/proxy.sh /etc/profile.d/proxy.sh.disabled 2>/dev/null

    # 清除环境变量
    systemctl --user set-environment http_proxy= https_proxy= all_proxy= HTTP_PROXY= HTTPS_PROXY= ALL_PROXY= 2>/dev/null

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 · SKILL.md (reported line 45)May include surrounding context.

部署命令:

bash
systemctl --user enable openclaw-watchdog.service
systemctl --user start openclaw-watchdog.service

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The documented purpose is monitoring, pause-state tracking, and restart, but the implementation also alters host configuration by disabling proxies. This mismatch increases operational risk because users and reviewers may deploy the skill expecting observability/recovery behavior, not configuration changes with security consequences.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script changes system and user proxy settings automatically without interactive confirmation or a strong user-facing warning. In this context, silent persistent configuration drift is a security issue because it can surprise operators, impair unrelated applications, and weaken expected network controls during routine watchdog execution.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
90% confidence
Finding

The use of sudo to move a file under /etc/profile.d grants the watchdog a path to make privileged persistent system changes. In this skill context, that is more dangerous because the stated role is service health management, yet it can alter root-owned host configuration when triggered by network errors.

Content

Scanner excerpt · scripts/watchdog.sh (reported line 174)May include surrounding context.

sh
log "⚠️ 网络异常,关闭系统代理..."

    # 禁用系统代理
    [ -f /etc/profile.d/proxy.sh ] && sudo mv /etc/profile.d/proxy.sh /etc/profile.d/proxy.sh.disabled 2>/dev/null

    # 清除环境变量
    systemctl --user set-environment http_proxy= https_proxy= all_proxy= HTTP_PROXY= HTTPS_PROXY= ALL_PROXY= 2>/dev/null

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 · scripts/watchdog.sh (reported line 230)May include surrounding context.

sh
sleep 3

    # 启动新进程(清除代理环境变量)
    nohup env -u http_proxy -u https_proxy -u all_proxy \
        -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY \
        openclaw gateway start > /tmp/openclaw_gateway.log 2>&1 &

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The human-facing comments and log messages are entirely in Chinese, including operational status output later in the script. Under the stated policy, forcing a specific language without opt-in can be a locale/language policy issue when no alternative or justification is provided.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.