T09 · Insecure Skill Coding Practices
- Location
scripts/sync_and_analyze.py:11- Finding
OS Command Injection via Environment-Controlled Workspace Path
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill mostly does what it says, but its helper script has a real shell-command injection risk through the workspace path, so it should be reviewed before installation.
Install only if you are comfortable with the skill cloning/updating ZLMediaKit, querying GitHub, and writing a local report. Before running the helper script, fix the shell=True command construction or run it in a tightly controlled workspace with a trusted WORKSPACE_DIR. Use a least-privilege GitHub token only when needed, and avoid configuring scheduled runs until the command-injection issue is corrected.
scripts/sync_and_analyze.py:11OS Command Injection via Environment-Controlled Workspace Path
Using a generic helper that invokes subprocess.run with shell=True is a genuine tool-parameter abuse pattern because it allows shell interpretation of dynamically built command strings. In this skill, environment-derived paths flow into commands such as git clone and can make the repository sync step dangerous if the runtime environment is attacker-influenced, leading to arbitrary command execution on the host.
def run_cmd(cmd, cwd=None):
print(f"Running: {cmd}")
result = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True)
if result.returncode != 0:
print(f"Error executing {cmd}:\n{result.stderr}")
return result.stdout.strip()
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
gh pr list -R ZLMediaKit/ZLMediaKit --limit 5 --state all
(注:如果没有 gh CLI,可以使用 curl -s https://api.github.com/repos/ZLMediaKit/ZLMediaKit/issues?per_page=5 替代)
Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.
- `SKILL.md`: OpenClaw 识别该 Skill 的元数据和工作流定义。
- `scripts/sync_and_analyze.py`: 一个 Python 辅助脚本,可直接运行来拉取代码并生成包含 Issue/PR 的报告 `zlmediakit_report.md`。
- `.trae/skills/zlmediakit-analyzer/SKILL.md`: 兼容 Trae IDE 格式的 Skill 描述文件。
## 如何使用
The README instructs users to set a GitHub personal access token in a persistent user environment variable without any guidance on secret sensitivity, least privilege, rotation, or avoiding accidental disclosure. In an agent/automation context, this increases the chance that credentials are over-scoped, stored longer than necessary, or exposed through logs, screenshots, shell history, or downstream tooling.
The skill declares powerful capabilities via metadata and workflow steps that involve shell execution, network access, and local repository writes, but it does not define a restrictive tool scope such as explicit permissions or allowed-tools. This increases the blast radius of prompt injection or accidental misuse because the agent may invoke broader tools than necessary when handling repository analysis tasks.
The trigger description is broad enough to match common user requests about ZLMediaKit updates, issues, PRs, or source analysis, which can cause the skill to activate unexpectedly. Unexpected activation is risky here because the workflow includes shell commands, repository synchronization, and outbound network access rather than purely local, read-only analysis.
The skill instructs the agent to run git clone/git pull and GitHub queries, which perform local file writes and outbound network access, but it does not clearly disclose those side effects to the user at execution time. This undermines informed consent and can surprise users with filesystem modifications or external requests triggered by what appears to be an analysis task.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
import argparse
REPO_URL = "https://github.com/ZLMediaKit/ZLMediaKit.git"
API_BASE = "https://api.github.com/repos/ZLMediaKit/ZLMediaKit"
WORKSPACE_DIR = os.environ.get("WORKSPACE_DIR", r"D:\.openclaw\workspace")
TARGET_DIR = os.path.join(WORKSPACE_DIR, "ZLMediaKit")
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
import argparse
REPO_URL = "https://github.com/ZLMediaKit/ZLMediaKit.git"
API_BASE = "https://api.github.com/repos/ZLMediaKit/ZLMediaKit"
WORKSPACE_DIR = os.environ.get("WORKSPACE_DIR", r"D:\.openclaw\workspace")
TARGET_DIR = os.path.join(WORKSPACE_DIR, "ZLMediaKit")
The script executes shell commands via subprocess.run(..., shell=True), which makes command parsing dependent on the shell and turns any attacker-influenced command string into a command-injection risk. In this skill, the command strings incorporate filesystem paths derived from WORKSPACE_DIR, so a maliciously crafted environment value could inject arbitrary shell metacharacters and execute unintended commands during git clone/pull or git log.
def run_cmd(cmd, cwd=None):
print(f"Running: {cmd}")
result = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True)
if result.returncode != 0:
print(f"Error executing {cmd}:\n{result.stderr}")
return result.stdout.strip()
This code accesses the sensitive GITHUB_TOKEN environment variable and sends it to GitHub via the Authorization header. Although the network fetch is part of the script's purpose, there is no explicit warning in code comments, docstrings, or user-facing output that credentials may be used and transmitted.
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
report_content = "\n".join(report_lines)
report_path = os.path.join(WORKSPACE_DIR, "zlmediakit_report.md")
with open(report_path, "w", encoding="utf-8") as f:
f.write(report_content)
print(f"\nReport generated at: {report_path}")
This markdown file states that the skill will automatically clone or update a repository into a fixed local workspace and generate a report file, which are user-data-affecting filesystem writes. While the behavior is described functionally, there is no clear warning or caution that running the skill will modify local files/directories.
L03 的整体描述仅以中文给出,且全文未说明是否支持按用户偏好切换语言或地区设置。根据语言/区域政策,若技能输出或交互被隐含地固定为单一语言,应提供用户选择或明确的适用范围。
The generated report includes Chinese-only headings and warning text, which imposes a specific language on output regardless of user preference. There is no opt-in, configuration, or justification indicating that the skill is intended to be Chinese-only or region-specific.