T06 · System Persistence
- Location
SKILL.md:174- Finding
Persistent execution through an on-logon scheduled task
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This watchdog skill is mostly aligned with its stated purpose, but it creates persistent auto-run behavior and can automatically kill local processes, modify configuration, store backups, and send log excerpts with insufficient safeguards.
Review this carefully before installing. Only use it on a machine where automatic OpenClaw restart, a logon scheduled task, config backup/restore, and possible Feishu notifications are acceptable. Avoid enabling the webhook or model failover unless you understand what data may leave the machine and what config may be rewritten, and do not run it with elevated privileges until process-kill and startup-path safeguards are improved.
SKILL.md:174Persistent execution through an on-logon scheduled task
scripts/watchdog_simple.py:200Arbitrary local process termination based only on port matching
scripts/watchdog_simple.py:468Potential disclosure of sensitive local log data to a configurable webhook
scripts/watchdog_simple.py:234Unnecessary shell invocation creates executable search-path hijacking risk
scripts/watchdog_simple.py:113Sensitive OpenClaw configuration is backed up using reversible Base64 encoding without encryption
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).
# 删除计划任务
schtasks /delete /tn "OpenClaw Gateway Guardian" /f
# 删除文件(可选)
rmdir /s %USERPROFILE%\.openclaw\watchdog
Recovery silently restores and overwrites the primary OpenClaw configuration file from backup. Because this happens automatically after downtime, users may lose intentional changes or have settings reverted without realizing it, and a manipulated backup source could push unsafe configuration back into production.
The script performs an unconditional force-kill of a process on a port with no confirmation or prominent safety disclosure. In a self-healing agent skill, this makes destructive behavior automatic and repeated, magnifying the operational impact of mistakes or hostile local conditions.
This is the same unsafe startup path: the watchdog spawns a command through the shell as part of self-recovery. Because the action is automatic and unattended, any path or environment hijack becomes more dangerous than a one-off manual command.
if check_port_in_use(GATEWAY_PORT):
kill_process_on_port(GATEWAY_PORT)
proc = subprocess.Popen(
["openclaw", "gateway", "start"],
cwd=OPENCLAW_DATA,
stdout=subprocess.DEVNULL,
This is the same unsafe startup path: the watchdog spawns a command through the shell as part of self-recovery. Because the action is automatic and unattended, any path or environment hijack becomes more dangerous than a one-off manual command.
if check_port_in_use(GATEWAY_PORT):
kill_process_on_port(GATEWAY_PORT)
proc = subprocess.Popen(
["openclaw", "gateway", "start"],
cwd=OPENCLAW_DATA,
stdout=subprocess.DEVNULL,
The skill documents capabilities that involve shell execution, file reads/writes, environment use, and network communication, but it does not declare any explicit tool scope or permissions boundary. That mismatch is dangerous because operators or platforms cannot accurately assess or constrain what the skill may do, increasing the chance of unexpected command execution, persistence setup, config modification, or outbound communication.
The Feishu webhook integration sends operational events such as downtime, recovery, and configuration-change notifications to an external service, but the skill does not present a clear privacy warning. This can expose infrastructure status, timing, and potentially sensitive configuration-related metadata to third parties or misconfigured recipients.
The skill creates persistence via a Windows scheduled task and automatically restarts the Gateway after crashes, but this behavior is not surfaced as an explicit warning in the skill description. Persistence and autonomous restart behavior can materially affect system control and incident response, and users may install it without realizing it will re-launch software at logon or after failure.
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
}
backup_file = BACKUP_DIR / f"config_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
with open(backup_file, 'w') as f:
json.dump(backup_info, f)
logger.info(f"✅ Config backed up: {backup_file}")
The script restores and overwrites openclaw.json automatically using a path derived from configurable/environment-controlled locations. In this watchdog context, automatic file overwrite during recovery can corrupt user settings or overwrite an unintended file if the data directory is redirected to an unsafe location.
return False
config_file = Path(OPENCLAW_DATA) / "openclaw.json"
with open(config_file, 'wb') as f:
f.write(data)
logger.info(f"✅ Config restored from: {backups[0]}")
The watchdog kills whichever process is listening on the configured gateway port, without confirming ownership. This is dangerous because port ownership is not identity: a legitimate unrelated service or a deliberately planted process could be terminated, causing denial of service or unsafe interference with other local applications.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def kill_process_on_port(port):
"""Kill process using the specified port"""
try:
result = subprocess.run(['netstat', '-ano'], capture_output=True, text=True)
for line in result.stdout.split('\n'):
if f':{port}' in line and 'LISTENING' in line:
parts = line.strip().split()
This call forcefully terminates a PID chosen only because it is listening on the configured port. In a watchdog skill, this is especially dangerous because it happens automatically and can kill unrelated local services if the port is reused, misconfigured, or intentionally occupied by another process.
if len(parts) >= 5:
pid = parts[-1]
logger.warning(f"⚠️ Killing process {pid} on port {port}")
subprocess.run(['taskkill', '/F', '/PID', pid], capture_output=True)
time.sleep(2)
return True
return False
The script launches openclaw with shell=True, which causes command resolution through the shell and current environment/PATH. In this skill context, configuration and environment-derived paths are used nearby, so an attacker who can influence PATH or the runtime environment could cause execution of an unintended program during automated recovery.
if check_port_in_use(GATEWAY_PORT):
kill_process_on_port(GATEWAY_PORT)
proc = subprocess.Popen(
["openclaw", "gateway", "start"],
cwd=OPENCLAW_DATA,
stdout=subprocess.DEVNULL,
The working directory passed to the child process is derived from configuration/environment-controlled data. While cwd alone is not code execution, in combination with shell=True and automated restart logic it increases the chance of executing or operating in an attacker-controlled location, making the startup path less trustworthy.
if check_port_in_use(GATEWAY_PORT):
kill_process_on_port(GATEWAY_PORT)
proc = subprocess.Popen(
["openclaw", "gateway", "start"],
cwd=OPENCLAW_DATA,
stdout=subprocess.DEVNULL,
The model failover feature edits the user's main configuration file automatically, but this destructive behavior is not clearly disclosed at the same level as a dangerous action should be. In this context, silent config mutation can alter model routing, cost, privacy, or compliance characteristics without the user's informed consent.
Automatic model failover writes modified configuration back to disk using a path derived from configurable/environment-controlled state. In context, this creates an unauthorized configuration mutation risk and could overwrite an unintended file if the target path is manipulated.
logger.info(f"🔄 Switching model: {current} -> {FALLBACK_MODEL}")
config['agents']['defaults']['model']['primary'] = FALLBACK_MODEL
with open(config_file, 'w', encoding='utf-8') as f:
json.dump(config, f, indent=2)
logger.info(f"✅ Model switched to: {FALLBACK_MODEL}")
The file contains bilingual content, but several key descriptions and operational headings are primarily Chinese-led and do not state any user-selectable language preference or locale justification. Under the policy, forcing or defaulting a specific language without opt-in can be a natural-language policy concern unless the locale constraint is documented and justified.