Back to skill

Security audit

OpenClaw Gateway Guardian

Security checks for vulnerabilities and agentic risk

Overview

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.

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

T06 · System Persistence

Error
Location
SKILL.md:174
Finding

Persistent execution through an on-logon scheduled task

Content
View full analysis
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/watchdog_simple.py:200
Finding

Arbitrary local process termination based only on port matching

Content
View full analysis
= 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 except Exception as e: logger.error(f"❌ Failed to kill process: {e}") return False ``` ```python if check_port_in_use(GATEWAY_PORT): kill_process_on_port(GATEWAY_PORT) ``` ### Technical Analysis Before starting OpenClaw, the watchdog forcibly terminates whichever process appears to be listening on the configured gateway port. It does not verify that the PID belongs to OpenClaw, that the executable path matches an expected binary, or that the process was originally created by the watchdog. The expression `f':{port}' in line` performs substring matching rather than parsing and comparing the exact local port. For example, a shorter configured port may also match a longer port number containing the same prefix. The use of `taskkill /F` prevents graceful shutdown and may interrupt writes or corrupt application state. Port conflict handling is useful for recovery, but forcibly killing an unidentified process exceeds the minimum privilege and scope required to check gateway availability. ### Attack Path 1. A legi ...[truncated 825 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/watchdog_simple.py:468
Finding

Potential disclosure of sensitive local log data to a configurable webhook

Content
View full analysis
= 32 or c in '\n\r\t') if len(sanitized) > 5000: sanitized = sanitized[:5000] + "\n... [truncated]" ``` ```python errors = get_recent_errors() send_feishu_notification( "🚨 OpenClaw 需要人工介入", f"连续崩溃次数: {crash_count} 次\n错误摘要: {errors[:500]}\n建议: 检查日志", "red" ) ``` ### Technical Analysis After repeated gateway failures, the code reads local OpenClaw logs and includes up to 500 characters of recent error content in a webhook notification. The implemented sanitization removes control characters but does not redact credentials, access tokens ...[truncated 1580 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Note
Location
scripts/watchdog_simple.py:234
Finding

Unnecessary shell invocation creates executable search-path hijacking risk

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/watchdog_simple.py:113
Finding

Sensitive OpenClaw configuration is backed up using reversible Base64 encoding without encryption

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
Findings (18)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
80% 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 · SKILL.md (reported line 187)May include surrounding context.

cmd
# 删除计划任务
schtasks /delete /tn "OpenClaw Gateway Guardian" /f

# 删除文件(可选)
rmdir /s %USERPROFILE%\.openclaw\watchdog

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

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.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

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.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
91% confidence
Finding

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.

Content

Scanner excerpt · scripts/watchdog_simple.py (reported line 235)May include surrounding context.

python
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,

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
91% confidence
Finding

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.

Content

Scanner excerpt · scripts/watchdog_simple.py (reported line 235)May include surrounding context.

python
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,

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

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.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

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.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

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.

Content

No source excerpt is available for this finding.

Tainted flow: 'backup_file' from os.environ.get (line 132, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/watchdog_simple.py (reported line 133)May include surrounding context.

python
}
        
        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}")

Tainted flow: 'config_file' from os.environ.get (line 318, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
88% confidence
Finding

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.

Content

Scanner excerpt · scripts/watchdog_simple.py (reported line 168)May include surrounding context.

python
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]}")

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

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.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/watchdog_simple.py (reported line 205)May include surrounding context.

python
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()

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
95% confidence
Finding

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.

Content

Scanner excerpt · scripts/watchdog_simple.py (reported line 212)May include surrounding context.

python
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

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
93% confidence
Finding

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.

Content

Scanner excerpt · scripts/watchdog_simple.py (reported line 235)May include surrounding context.

python
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,

Tainted flow: 'OPENCLAW_DATA' from os.environ.get (line 63, credential/environment) → subprocess.Popen (code execution)

Medium
Category
Data Flow
Confidence
82% confidence
Finding

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.

Content

Scanner excerpt · scripts/watchdog_simple.py (reported line 235)May include surrounding context.

python
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,

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

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.

Content

No source excerpt is available for this finding.

Tainted flow: 'config_file' from os.environ.get (line 318, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
87% confidence
Finding

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.

Content

Scanner excerpt · scripts/watchdog_simple.py (reported line 333)May include surrounding context.

python
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}")

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

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.

Content

No source excerpt is available for this finding.