Back to skill

Security audit

feishu-duoge002

Security checks for vulnerabilities and agentic risk

Overview

This skill appears to be a real Feishu bot setup helper, but it changes persistent OpenClaw configuration with unsafe defaults and contains a command-injection risk in its setup script.

Review this skill carefully before installing. Only run the setup script with a config file you fully trust, because a malicious agentId can trigger local shell command execution. Back up ~/.openclaw/openclaw.json first, protect Feishu secrets in the input and generated config, and change the generated bot access policies to an allowlist with mention-required behavior before using it in any shared or production Feishu environment.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/setup_bots.py:125
Finding

Arbitrary Shell Command Injection Through Unvalidated agentId

Content
View full analysis
str: """运行命令并返回输出""" print(f"Running: {cmd}") result = subprocess.run(cmd, shell=True, capture_output=True, text=True) if check and result.returncode != 0: print(f"Error: {result.stderr}") print(f"Exit code: {result.returncode}") return "" return result.stdout ``` ```python agent_id = bot['agentId'] ``` ```python if not exists: # 创建 agent run_command(f"openclaw agents add {agent_id} --workspace {workspace_path} --non-interactive") ``` ### Technical Analysis The `agentId` field is read directly from the operator-supplied JSON configuration and interpolated into a command string. The resulting string is passed to `subprocess.run()` with `shell=True`. Because no allowlist validation or shell-safe argument separation is applied, shell metacharacters in `agentId` are interpreted by the command shell rather than treated as literal identifier characters. The derived `workspace_path` also embeds the same untrusted value in the command. This permits command substitution, command chaining, redirection, pipelines, or similar shell syntax. The vulnerability does not require a defect in the `openclaw` executable; exploitation occurs in the shell before or while that executable is invoked. ### Attack Path 1. An attacker obtains the ability to create or modify the JSON configuration passed to `setup_bots.py`. 2. The attacker places shell syntax in a bot's `agentId`, such as an identifier followed by a command separator and an attacker-selected command. 3. The operator executes: ```bash python3 scripts/setup_bots.py /path/to/bots_config.json ``` 4. The script reads the malicious `agentId` without valid ...[truncated 1217 chars]
Remediation
View remediation
str: print(f"Running: {cmd!r}") result = subprocess.run( cmd, shell=False, capture_output=True, text=True, check=False, ) if check and result.returncode != 0: print(f"Error: {result.stderr}") print(f"Exit code: {result.returncode}") return "" return result.stdout run_command([ "openclaw", "agents", "add", agent_id, "--workspace", workspace_path, "--non-interactive", ]) ``` Apply defense in depth: 1. Validate `agentId` before using it in a path or command. Use a conservative allowlist such as `^[A-Za-z0-9_-]+$` and impose a reasonable maximum length. 2. Reject identifiers containing path separators, traversal components, whitespace, control characters, or shell metacharacters. 3. Construct workspace paths with `pathlib.Path`, resolve them, and verify that the resolved path remains beneath the intended `~/.openclaw/agents` directory. 4. Validate the complete configuration against a schema before making any filesystem or configuration changes. 5. Avoid logging secrets or complete command material if future arguments may contain sensitive values. 6. Fail safely when agent creation fails instead of updating the central configuration as though creation succeeded. ]]>

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/setup_bots.py:168
Finding

Generated Bots Permit Unrestricted Direct-Message and Group Access

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (7)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
98% confidence
Finding

This is a concrete tool-parameter abuse issue because untrusted configuration data is incorporated into a shell command. In the context of a setup utility that consumes external JSON and performs system-level changes, shell injection is especially dangerous because it can execute arbitrary local commands and tamper with persistent agent configuration.

Content

Scanner excerpt · scripts/setup_bots.py (reported line 15)May include surrounding context.

python
def run_command(cmd: str, check: bool = True) -> str:
    """运行命令并返回输出"""
    print(f"Running: {cmd}")
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    if check and result.returncode != 0:
        print(f"Error: {result.stderr}")
        print(f"Exit code: {result.returncode}")

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The documentation instructs users to place Feishu credentials such as appSecret, encryptKey, and verificationToken directly into a JSON file, and also discusses extracting user IDs from gateway logs, but gives no warning about secure storage, redaction, file permissions, or log exposure. This creates a realistic risk of accidental credential leakage through source control, shell history, shared filesystems, backups, or operational logs.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
97% confidence
Finding

The script invokes subprocess.run with shell=True and builds the command from interpolated bot-controlled values later in the file, specifically agent_id and workspace_path in the openclaw agents add command. If a crafted config supplies shell metacharacters in agentId, this can lead to arbitrary command execution under the privileges of the user running the setup script.

Content

Scanner excerpt · scripts/setup_bots.py (reported line 15)May include surrounding context.

python
def run_command(cmd: str, check: bool = True) -> str:
    """运行命令并返回输出"""
    print(f"Running: {cmd}")
    result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
    if check and result.returncode != 0:
        print(f"Error: {result.stderr}")
        print(f"Exit code: {result.returncode}")

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The script ingests appSecret and other bot credentials from the config and persists them into ~/.openclaw/openclaw.json without any explicit warning, masking, or file-permission checks. This increases the chance that operators mishandle secrets, store them in insecure locations, or expose them through backups, logs, or overly permissive filesystem settings.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script writes directly to the user's global ~/.openclaw/openclaw.json after modifying routing, agent, and account settings, with no confirmation, backup, or dry-run behavior. A malformed or hostile config file can therefore silently alter global bot behavior, break existing setups, or reroute traffic to attacker-controlled accounts.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The skill recommends running an automated setup script and restarting the gateway, but does not warn that these actions modify active configuration and may interrupt service or affect production bots. In an operational environment, this omission can lead to unintended downtime, misconfiguration, or disruption if users follow the instructions on a live system without validation or rollback planning.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The module-level description is written as a Chinese-only operational description for the setup script, with no indication that language can be selected or that the tool is intentionally limited to a Chinese-speaking audience for compliance or regional reasons. Under the policy, fixed language constraints without opt-in or justification should be flagged.

Content

No source excerpt is available for this finding.