Back to skill

Security audit

Openclaw Config Expert

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly an OpenClaw configuration admin tool, but it also enables broad automatic mutations, service restarts, scheduled tasks, and an undeclared persistent prompt rewrite that users should review before installing.

Install only if you are comfortable with an admin skill that can persistently change OpenClaw configuration, restart services, manage plugins, and set scheduled jobs. Review or remove scripts/knowledge_optimization.py, avoid broad auto-routing for mutating commands, require confirmation before rollback/restart/migration/plugin changes, and protect backups and secrets with restrictive permissions.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/emergency_recovery.py:141
Finding

Overbroad Gateway Process Termination

Content
View full analysis

Vulnerability Details

File Locations:

  • scripts/emergency_recovery.py:141-155
  • config_validator.py:460-464

Vulnerability Type: Unscoped process termination
Risk Level: Medium

Vulnerable Code

python
# scripts/emergency_recovery.py:141-155

subprocess.run(
    ["pkill", "-f", "openclaw.*gateway"],
    capture_output=True
)

# Wait for the port to be released
import time
time.sleep(2)

# Start Gateway
log("Starting Gateway...")
subprocess.Popen(
    ["openclaw", "gateway", "start"],
    stdout=subprocess.DEVNULL,
    stderr=subprocess.DEVNULL
)
python
# config_validator.py:460-464

subprocess.run(
    ["pkill", "-f", "openclaw.*gateway"],
    capture_output=True,
    timeout=10
)
time.sleep(2)

subprocess.Popen(
    ["openclaw", "gateway", "start"],
    stdout=subprocess.DEVNULL,
    stderr=subprocess.DEVNULL
)

Technical Analysis

Both restart implementations use pkill -f with the regular expression openclaw.*gateway. The -f option matches against the entire process command line rather than a verified executable name or trusted process identifier.

The expression can therefore match processes other than the intended OpenClaw Gateway. The code does not verify:

  • The path of the matched executable.
  • The process owner.
  • Whether the process was started by this OpenClaw installation.
  • Whether the process is listening on the expected Gateway port.
  • Whether a matched PID came from a trusted Gateway PID file.
  • Whether more than one process matched before termination.

The subprocess calls do not use a shell, so this is not shell command injection. The vulnerability is instead an insufficiently scoped process-management operation.

Attack Path

  1. A local process is started with a command line containing text that matches openclaw.*gateway.
  2. A user or automated agent invokes Gateway recovery or restart.
  3. The Skill executes pkill -f openclaw.*gateway.
  4. The unrelated matching process receives a terminati ...[truncated 1139 chars]
Remediation
View remediation

Remediation Suggestions

  1. Prefer the application's supported lifecycle interface:

    python
    subprocess.run(
        ["openclaw", "gateway", "stop"],
        check=True,
        capture_output=True,
        timeout=10
    )
    
  2. If direct signaling is necessary, use a trusted PID file created by the Gateway. Parse the PID as an integer and reject invalid or stale values.

  3. Before signaling a PID, verify all of the following:

    • The process is owned by the expected user.
    • Its executable resolves to the expected OpenClaw binary.
    • Its start time matches the managed instance where possible.
    • Its command-line arguments represent the intended Gateway instance.
    • It is associated with the expected configuration or port.
  4. Signal only the verified PID rather than performing a regular-expression search across all process command lines.

  5. Attempt graceful termination first, wait for a bounded period, and use forced termination only after explicit verification.

  6. Check and report the return codes of both stop and start operations. Do not suppress all startup diagnostics; write errors to a protected log.

  7. Add tests demonstrating that similarly named unrelated processes are not terminated.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/agents.py:43
Finding

Sensitive Configuration Backup Created Without Explicit Restrictive Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/agents.py:43-50
Vulnerability Type: Potential plaintext credential exposure through backup permissions
Risk Level: Low

Vulnerable Code

python
# Backup the original configuration
backup_path = self.config_path.with_suffix('.json.bak')
backup_path.write_text(
    self.config_path.read_text(encoding='utf-8'),
    encoding='utf-8'
)
print(f"Backup saved: {backup_path}")

# Save the new configuration
with open(self.config_path, 'w', encoding='utf-8') as f:
    json.dump(self.config, f, ensure_ascii=False, indent=2)

Technical Analysis

The agent manager copies the complete OpenClaw configuration into openclaw.json.bak. The audited project indicates that this configuration may contain sensitive values such as:

  • Model-provider API keys.
  • Plugin bridge tokens.
  • Feishu application secrets.
  • Enterprise messaging integration secrets.

Path.write_text() creates the backup using permissions derived from the process umask. The code does not explicitly require mode 0600, verify the permissions after creation, or confirm that the parent directory is inaccessible to other users.

This does not guarantee exposure on every installation. A restrictive umask and a private ~/.openclaw directory may adequately protect the file. Nevertheless, relying exclusively on environmental defaults is unsafe for a file expected to contain authentication material.

The subsequent write to the primary configuration is also non-atomic. A failure during serialization or writing could leave the active configuration partially written, although this primarily creates an integrity and availability risk.

Attack Path

The confidentiality issue is exploitable under the following conditions:

  1. The active OpenClaw configuration contains plaintext credentials or tokens.
  2. The user invokes an agent add, remove, or update operation.
  3. save_config() creates or replaces openclaw.json.bak.
  4. The process has a ...[truncated 1025 chars]
Remediation
View remediation

Remediation Suggestions

  1. Create backup files with owner-only permissions from the outset:

    python
    import os
    
    backup_path = self.config_path.with_suffix(".json.bak")
    fd = os.open(
        backup_path,
        os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
        0o600
    )
    with os.fdopen(fd, "w", encoding="utf-8") as backup_file:
        backup_file.write(self.config_path.read_text(encoding="utf-8"))
    
  2. Apply and verify mode 0600 on both the active configuration and every backup:

    python
    os.chmod(backup_path, 0o600)
    os.chmod(self.config_path, 0o600)
    
  3. Verify that ~/.openclaw is owned by the expected user and has restrictive directory permissions, such as 0700.

  4. Use an atomic backup and configuration-write procedure:

    • Create a temporary file in the same protected directory.
    • Set restrictive permissions immediately.
    • Write and flush the complete JSON.
    • Call os.fsync() where durability is required.
    • Replace the destination with os.replace().
  5. Avoid retaining plaintext credentials in unnecessary backups. Where supported, preserve environment-variable references or secret-store identifiers instead of resolved secret values.

  6. Define a bounded backup-retention policy and securely remove obsolete backups.

  7. Refuse to follow unexpected symbolic links and verify that the destination is a regular file owned by the expected account before replacing it.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (77)

Tp4

High
Category
MCP Tool Poisoning
Confidence
88% confidence
Finding

描述覆盖面明显大于代码实际能力。代码确实与“Agent 智能配置”“模型路由优化”“配置分析”部分相符,但并不是一个全面的 OpenClaw 配置管理专家。它只读取单个 JSON 配置文件,并聚焦 agents 段的分析、创建模板、路由建议和子 Agent 权限优化;没有看到插件管理、版本升级/迁移、回滚恢复、Gateway 重启、配置自动修复并写回文件等关键声明能力。因此描述对功能范围有实质性夸大,属于描述与行为不完全匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

声明描述的是“配置管理专家”型能力,重点在配置校验、修复、优化、路由、版本迁移和恢复建议/操作;而提供的代码块主要实现的是定时任务编排与测试,不是配置内容本身的分析或修复。虽然其中部分定时任务与“配置验证”“健康检查”有关,属于配置管理生态的相关支持功能,但该代码的主要职责明显是 Cron 管理,而不是声明中的配置专家能力。此外,代码还包含未在声明中明确体现的能力:创建/列出定时任务,以及清理备份文件(删除旧文件),这些都属于额外的运维自动化能力。因此描述与实际行为存在实质性不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The code is clearly related to configuration management, but only within the narrower scope of plugin management in the OpenClaw config file. It reads and writes ~/.openclaw/openclaw.json, validates some plugin-specific fields, checks dependencies/conflicts, enables/disables plugins, and produces reports. That aligns with the plugin-management portion of the description. However, the declared purpose is much broader and suggests a general configuration expert with version awareness, migration assistance, rollback/recovery, gateway restart handling, agent modification, and model routing optimization. None of those broader capabilities are present in this code chunk. Additionally, there is a concrete implementation issue: generate_plugin_report uses datetime.now() without importing datetime, which further indicates the code is limited and not a comprehensive configuration expert. Therefore, this is a material description-behavior mismatch due to significant overstatement of capabilities beyond plugin config management.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

描述将该技能定位为全面的 OpenClaw 配置管理与修复专家,但代码范围明显更窄:它只是一个针对 Agent 配置的 CLI 工具。虽然其行为与“修改 agent”这一子场景一致,也确实会操作配置文件并做备份,但并未实现描述中的大多数核心能力,如配置校验修复、最佳实践分析、模型路由优化、插件管理、版本升级迁移、回滚恢复或 Gateway 重启。因此描述显著夸大了能力范围,属于描述与实际行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

描述把该技能定位为广泛的“配置管理专家”,覆盖配置验证修复、Agent 调优、路由优化、插件管理、版本迁移等多个高级能力;但代码仅实现了一个较窄的运维/灾难恢复工具:检查本地 Gateway 状态、恢复 JSON 备份、回滚配置、重启 Gateway、记录日志。虽然描述中提到“紧急恢复”“回滚”“恢复”“重启 Gateway”,与脚本部分行为一致,但这些只是描述中的一小部分,且代码的主功能明显集中在恢复脚本而非通用配置管理。因此存在显著的描述与实际行为不一致。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

声明描述强调的是通用 OpenClaw 配置管理与修复能力,如配置验证、路由优化、版本迁移、回滚恢复等;而实际代码的核心目的并不是验证或修复配置,而是进行知识库/模型能力增强。它写入 ~/.ollama/modelfiles 下的 Modelfile,调用 Ollama 创建模型,并定向修改 OpenClaw 配置中的 psychology-analyst agent 的 system_prompt。这属于模型定制和知识注入,而不是所宣称的配置管理专家行为。虽然代码确实接触了 openclaw.json 配置文件,存在一定“配置修改”表象,但其主要功能与声明的配置治理、验证、版本感知、路由优化并不一致,且包含未声明的外部模型创建与知识库优化能力,因此构成明显不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

描述显著夸大了能力范围。代码的核心功能仅是“验证”配置并给出警告/建议,属于只读检查工具;虽然会提供一些最佳实践式提示(如 auth mode、Feishu groupPolicy 建议),但并未实现声明中的关键管理能力,例如自动修复、配置写回、版本检测与迁移、插件管理、路由优化、恢复/回滚、重启 Gateway。主用途从‘全功能配置管理专家’实际收缩为‘配置验证器’,因此描述与实际行为存在实质性不匹配。

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script modifies an unrelated psychology/sales agent's system prompt, which is outside the stated mission of an OpenClaw configuration expert and creates stealthy, persistent instruction changes. This is especially dangerous in skill context because it alters another agent's downstream behavior without clear user intent, potentially manipulating outputs, business conduct, or trust decisions over time.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The document instructs operators to deploy Cron tasks and describes automatic Gateway restarts, both of which are system-level actions with persistence and availability impact, but it does not prominently warn users that these operations modify host scheduling and may restart a live service. In the context of a configuration-management skill, this increases the risk of unintended service disruption or unauthorized persistence if a user follows the instructions without understanding the consequences.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The document explicitly states that configuration-related natural language will be automatically routed to a privileged configuration skill instead of the default agent. In this context, broad trigger matching can cause unintended execution of validation, modification, optimization, or recovery flows from ordinary conversational phrases, increasing the risk of unauthorized or accidental state changes.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The document promotes automatic execution of commands that can alter configuration or trigger emergency recovery, but does not clearly warn about side effects such as service restarts, state rollback, plugin changes, or disruption to running systems. Without explicit safety notices and execution gates, users may trigger impactful operations without understanding operational consequences.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The examples include high-collision phrases such as '崩溃了', '启动不了', and '调优', which may appear in general discussion but are mapped to actionable commands. In a routing layer for configuration management, this makes accidental escalation from chat text to operational commands more likely, especially for sensitive actions like recovery or migration.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The documented routing rule uses highly generic regex patterns like '把.*改成' and '设置.*为', which can match many unrelated user messages. When tied to 'python3 config.py modify', this creates a clear path from loosely matched text to configuration mutation, making misrouting and unintended changes materially dangerous in this skill context.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill advertises and documents file modification, shell execution, and network operations, but declares no explicit tool scope or permission boundaries. In an agent environment, this can enable unintended high-privilege actions such as editing live configuration, restarting services, or making outbound requests without user-visible guardrails.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The trigger phrases are very broad and likely to match routine user requests about configuration, tuning, recovery, or routing. That increases the chance this skill is invoked in contexts where users did not intend to authorize file changes, service restarts, or operational diagnostics.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill describes automatic rollback and gateway restart during emergency recovery without prominent warnings about live-system modification, downtime, or the need for user approval. In practice, this could cause unexpected service interruption, revert intended changes, or overwrite operational state under the guise of recovery.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The configuration modification, optimization, plugin toggling, and migration examples all imply persistent changes and potential gateway restart, yet they omit strong warnings about service disruption and lasting effects. Users may interpret these as safe routine operations and unintentionally authorize destructive or production-impacting changes.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The regex routing rules use generic keywords like 配置, 优化, 修改, 模型, 插件, 恢复, and 路由 with little context. In an agent router, this can misroute ordinary conversations into a skill capable of shell commands and persistent system changes, creating a real authorization and safety problem.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill directs process inspection, port inspection, service restart, and manual gateway start operations, which are operationally sensitive actions not tightly bounded by the skill metadata. In a semi-autonomous agent, this can lead to disruptive changes, unintended downtime, or use of elevated shell capabilities without explicit authorization boundaries.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The documentation includes generic network diagnostics and external connectivity tests that go beyond narrow configuration analysis, including reaching third-party endpoints. In agent settings, such guidance can normalize outbound probing and log inspection without clearly limiting when these actions are appropriate or what data might be exposed.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

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

md
echo $HTTPS_PROXY

# 测试网络连通性
curl -v https://api.deepseek.com/v1/models

# 查看错误日志
tail -100 ~/.openclaw/logs/gateway.log

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The optimizer directly rewrites subagent permission scopes by setting defaults['subagents']['allowAgents'] to all agent IDs and expanding coordinator access to every agent, without user confirmation, diff preview, or least-privilege checks. In a configuration-management skill whose purpose includes modifying agents, routing, rollback, and recovery, this can silently broaden lateral access between agents and undermine existing trust boundaries, making privilege escalation or unintended data/tool access more likely.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

This entrypoint exposes high-impact actions such as recover, rollback, and restart and immediately dispatches them to helper scripts without any confirmation prompt or user-facing warning. In a skill intended for configuration and emergency recovery, that increases the chance of accidental disruptive operations, especially when triggered by an agent or ambiguous user request.

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 · config.py (reported line 60)May include surrounding context.

python
return 1
    
    cmd = [sys.executable, str(script_path)] + args
    result = subprocess.run(cmd)
    return result.returncode

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The README explicitly tells users to set API keys and application secrets via shell export commands, but provides no warning that these values may be exposed through shell history, shared terminals, process inspection in some environments, or accidental copy/paste into logs and tickets. Because this skill is specifically about configuration management and production-oriented setup, users are likely to follow these commands verbatim with real credentials, increasing the chance of credential leakage.

Content

No source excerpt is available for this finding.