Back to skill

Security audit

create-feishu-agent Skill

Security checks for vulnerabilities and agentic risk

Overview

The skill has a clear Feishu-agent setup purpose, but its helper script and defaults can expose Feishu secrets, overwrite unintended agent files, and let the bot process group messages without being addressed.

Review before installing. Use this only in a trusted local environment, avoid the helper script until agent-name validation and heredoc handling are fixed, rotate any secret passed on a command line, restrict file permissions on OpenClaw config, and prefer requiring mentions or limiting the bot to specific chats.

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

T09 · Insecure Skill Coding Practices

Error
Location
create-feishu-agent.sh:89
Finding
<![CDATA[Arbitrary Python Code Execution Through Unsafe Heredoc Interpolation]]><![CDATA[ ## Vulnerability Details **File Location**: `create-feishu-agent.sh:89-98` **Vulnerability Type**: Python source injection **Risk Level**: High ### Vulnerable Code ```bash # Use Python to update the configuration python3 << PYTHON_SCRIPT import json import sys config_file = "$CONFIG_FILE" agent_name = "$AGENT_NAME" display_name = "$DISPLAY_NAME" app_id = "$APP_ID" app_secret = "$APP_SECRET" workspace = "$WORKSPACE" ``` ### Technical Analysis The heredoc delimiter is unquoted, and values derived from command-line arguments are interpolated directly into generated Python source code. The script does not escape quotation marks, newlines, backslashes, or Python syntax before placing these values inside Python string literals. An attacker who can influence any of the arguments—particularly `agent_name`, `display_name`, `app_id`, or `app_secret`—can terminate the generated string literal and inject additional Python statements. Those statements execute under the account and privileges of the user running the script. This is not limited to corrupting the JSON configuration. Injected Python can invoke operating-system commands, read local credentials, modify Agent instructions, or overwrite any file accessible to the invoking user. ### Attack Path 1. An attacker convinces a user or automation workflow to run the script with a crafted argument. 2. The malicious argument contains a quote, newline, and valid Python statements that escape the intended assignment. 3. The shell interpolates the argument into the heredoc used as Python source. 4. `python3` parses the attacker-controlled statements as executable code. 5. The payload executes with the privileges of the user running the setup script. For example, a malicious value can conceptually transform: ```python display_name = "<attacker-controlled value>" ``` into multiple Python statements, including calls to `os.system()` or `subprocess`. ### Impact Assessment Successful exploitation provides ar ...[truncated 499 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Do not construct Python source by interpolating shell variables. Use a quoted heredoc and pass data through positional arguments or environment variables. A safer pattern is: ```bash python3 - "$CONFIG_FILE" "$AGENT_NAME" "$DISPLAY_NAME" "$APP_ID" "$APP_SECRET" "$WORKSPACE" <<'PYTHON_SCRIPT' import json import sys config_file, agent_name, display_name, app_id, app_secret, workspace = sys.argv[1:7] with open(config_file, "r", encoding="utf-8") as file: config = json.load(file) # Perform validated configuration updates here. PYTHON_SCRIPT ``` Additional hardening should include: 1. Validate `AGENT_NAME` against a strict allowlist such as `^[A-Za-z0-9_-]+$`. 2. Apply reasonable length limits to every argument. 3. Treat display names and credentials exclusively as data, never generated source. 4. Write configuration changes to a securely created temporary file and atomically replace the original only after successful validation. 5. Preserve restrictive permissions on configuration files containing secrets. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
create-feishu-agent.sh:14
Finding
<![CDATA[Path Traversal Allows Files to Be Written Outside the Agent Directory]]><![CDATA[ ## Vulnerability Details **File Location**: `create-feishu-agent.sh:14-74` **Vulnerability Type**: Path traversal and arbitrary file overwrite **Risk Level**: High ### Vulnerable Code ```bash AGENT_NAME=$1 DISPLAY_NAME=$2 APP_ID=$3 APP_SECRET=$4 WORKSPACE="$HOME/.openclaw/workspace" AGENT_DIR="$WORKSPACE/agents/$AGENT_NAME" CONFIG_FILE="$HOME/.openclaw/openclaw.json" echo "=== 创建飞书 Agent: $AGENT_NAME ===" # 1. 创建目录结构 echo "[1/5] 创建目录结构..." mkdir -p "$AGENT_DIR/memory" # 2. 创建 SOUL.md echo "[2/5] 创建 SOUL.md..." cat > "$AGENT_DIR/SOUL.md" << 'EOF' # SOUL.md - <DISPLAY_NAME> _一句话描述你的agent_ ## Core Truths **原则1。** 解释... **原则2。** 解释... ## What You Do ### 功能1 - 具体说明 ## Boundaries - 边界1 - 边界2 ## Vibe 性格描述 EOF sed -i '' "s/<DISPLAY_NAME>/$DISPLAY_NAME/g" "$AGENT_DIR/SOUL.md" # 3. 创建 AGENTS.md echo "[3/5] 创建 AGENTS.md..." cat > "$AGENT_DIR/AGENTS.md" << EOF # AGENTS.md - $DISPLAY_NAME Workspace 继承主 workspace 规则。 ## 职责 - 职责1 - 职责2 EOF # 4. 创建 MEMORY.md echo "[4/5] 创建 MEMORY.md..." cat > "$AGENT_DIR/MEMORY.md" << 'EOF' # MEMORY.md - 长期记忆 ``` ### Technical Analysis `AGENT_NAME` is accepted without validation and appended directly to the intended Agent root: ```bash AGENT_DIR="$WORKSPACE/agents/$AGENT_NAME" ``` Quoting the resulting path prevents word splitting but does not prevent path traversal. An input containing `../` components can resolve outside `$WORKSPACE/agents`. The subsequent redirections use truncating writes. Therefore, if the resolved destination contains existing files named `SOUL.md`, `AGENTS.md`, or `MEMORY.md`, those files are replaced without confirmation. The script can also create a `memory` directory at the escaped destination. Because these filenames have special meaning in OpenClaw workspaces, traversal into another Agent directory can corrupt or replace that Agent's persistent instructions and memory. ### Attack Path 1. An attacker supplies an Agent name containing traversal components, such as a value resol ...[truncated 1173 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Validate the Agent name before using it in a filesystem path: ```bash if [[ ! "$AGENT_NAME" =~ ^[A-Za-z0-9_-]+$ ]]; then echo "Invalid agent name: use only letters, digits, underscores, and hyphens." >&2 exit 1 fi ``` Then canonicalize and verify the destination: ```bash AGENTS_ROOT="$WORKSPACE/agents" mkdir -p "$AGENTS_ROOT" AGENTS_ROOT_REAL="$(cd "$AGENTS_ROOT" && pwd -P)" AGENT_DIR="$AGENTS_ROOT/$AGENT_NAME" AGENT_PARENT_REAL="$(cd "$(dirname "$AGENT_DIR")" && pwd -P)" if [[ "$AGENT_PARENT_REAL" != "$AGENTS_ROOT_REAL" ]]; then echo "Agent directory escapes the permitted root." >&2 exit 1 fi ``` Further hardening should include: 1. Reject empty names, dot components, path separators, and control characters. 2. Refuse to overwrite an existing Agent unless the user explicitly provides a safe overwrite flag. 3. Create files with `noclobber` or perform existence checks where replacement is unnecessary. 4. Stage generated files in a secure temporary directory beneath the validated root. 5. Atomically move validated files into place. 6. Add tests covering `../`, absolute paths, symbolic links, empty names, and unusual Unicode separators. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
create-feishu-agent.sh:3
Finding
<![CDATA[Feishu App Secret Is Exposed Through Command-Line Arguments]]><![CDATA[ ## Vulnerability Details **File Location**: `create-feishu-agent.sh:3-17` **Additional Location**: `QUICK_REF.md:6-13` **Vulnerability Type**: Sensitive credential exposure **Risk Level**: Medium ### Vulnerable Code ```bash #!/bin/bash # create-feishu-agent.sh - 快速创建飞书 Agent # 用法: ./create-feishu-agent.sh <agent_name> <display_name> <app_id> <app_secret> set -e if [ $# -lt 4 ]; then echo "用法: $0 <agent_name> <display_name> <app_id> <app_secret>" echo "示例: $0 health_manager '健康助手' cli_xxx xxx" exit 1 fi AGENT_NAME=$1 DISPLAY_NAME=$2 APP_ID=$3 APP_SECRET=$4 ``` The reference documentation also instructs users to place the secret directly in the command: ```bash ~/.openclaw/workspace/skills/create-feishu-agent/create-feishu-agent.sh \ <agent_name> "<显示名称>" <app_id> <app_secret> ~/.openclaw/workspace/skills/create-feishu-agent/create-feishu-agent.sh \ tech_expert "技术专家" cli_xxx xxxsecret ``` ### Technical Analysis The script requires the Feishu App Secret as its fourth command-line argument. Command-line arguments are not an appropriate transport for long-lived credentials because they can be recorded or observed through mechanisms outside the script's control. Depending on the environment, the secret may be exposed through: - Interactive shell history. - Process inspection utilities while the script is running. - Process accounting or endpoint-monitoring systems. - Automation logs that record invoked commands. - Terminal transcripts, troubleshooting output, or copied command examples. The documentation reinforces this unsafe usage pattern instead of providing a protected input mechanism. ### Attack Path 1. A user invokes the script with the real Feishu App Secret as the fourth argument. 2. The complete command is stored in shell history, automation logs, or process-monitoring records. 3. Another user, administrator, support operator, or compromised process obtains those records. 4. The observer extracts the App ID and Ap ...[truncated 823 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Remove the secret from the command-line interface. Prompt for it without terminal echo: ```bash if [[ -z "${APP_SECRET:-}" ]]; then read -r -s -p "Feishu App Secret: " APP_SECRET printf '\n' fi ``` Preferably, integrate with an operating-system keychain, secret manager, or protected file descriptor. If environment variables are supported for automation, document their exposure limitations and ensure they are not logged. Additional protections should include: 1. Update `SKILL.md` and `QUICK_REF.md` so no example places a real secret on the command line. 2. Avoid printing or tracing the secret; explicitly reject execution under shell tracing if necessary. 3. Set restrictive permissions on `~/.openclaw/openclaw.json`, such as owner read/write only. 4. Ensure backup files containing old credentials receive the same restrictive permissions. 5. Rotate any secret previously used in recorded command lines. 6. Redact credentials from CI logs, process telemetry, and support bundles. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (8)

Missing User Warnings

High
Confidence
98% confidence
Finding
The document explicitly recommends `groupPolicy: "open"` and `requireMention: false`, allowing the agent to process all group messages without being addressed. This materially increases passive message collection, accidental triggering, and the chance that sensitive group content is ingested or acted on without clear user intent.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The trigger conditions are broad natural-language phrases such as 'create a new agent' and 'add Feishu bot', which can overlap with ordinary discussion and cause the skill to activate unexpectedly. In a skill that creates files, edits configuration, and binds messaging channels, accidental activation can lead to unintended workspace changes or bot deployment.

Session Persistence

Medium
Category
Rogue Agent
Content
```bash
# 在 workspace/agents/ 下创建新 agent
mkdir -p ~/.openclaw/workspace/agents/<agent_name>

# 必需文件
touch ~/.openclaw/workspace/agents/<agent_name>/SOUL.md      # 人设文件
Confidence
60% 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.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill instructs operators to record and place `App Secret` directly into configuration but provides no guidance on secure secret handling. This creates a realistic risk of credentials being stored in plaintext, copied into logs, committed to repositories, or exposed through permissive filesystem access.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The script persists the provided Feishu app credentials directly into a long-lived JSON config under the user's home directory, and it does so without checking file permissions, offering a safer secret store, or clearly warning the operator that sensitive credentials will be written to disk. If the config file is readable by other local users, copied into backups, committed accidentally, or harvested by malware, the appId/appSecret can be exposed and used to impersonate or control the configured Feishu integration.

Natural-Language Policy Violations

Low
Confidence
91% confidence
Finding
This markdown file presents all instructions, headings, and operational guidance in Chinese only. Under the policy rule for language or locale constraints, this can be a natural-language policy violation when the skill forces a specific language without user opt-in or justification.

Natural-Language Policy Violations

Low
Confidence
72% confidence
Finding
整份技能说明与模板均仅以中文编写,并未说明这是面向特定中文用户群或区域场景的限定,也未提供其他语言选项。若该技能面向通用用户,这种默认强制单一语言可能构成语言/locale 策略上的不充分选择。

Natural-Language Policy Violations

Low
Confidence
94% confidence
Finding
Comments, usage output, progress messages, and generated markdown content are written in Chinese throughout the script. This imposes a specific language on all users without opt-in or documentation that the skill is intended only for a Chinese-speaking or region-specific context.