T09 · Insecure Skill Coding Practices
- Location
video_producer.py:66- Finding
Command Injection Through Shell-Based Edge TTS and FFmpeg Execution
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This video-generation skill matches its stated purpose, but it needs review because user-provided content can reach shell commands and API credentials/content can be sent to configurable external services.
Review before installing. Use it only in a sandboxed working directory, avoid processing untrusted video text or output paths, do not set OPENAI_BASE to an untrusted proxy, and prefer a version that removes shell=True, validates API hosts, and clearly documents what content and credentials are sent to MiniMax/OpenAI/Edge services.
video_producer.py:66Command Injection Through Shell-Based Edge TTS and FFmpeg Execution
video_producer.py:53OpenAI API Credentials and User Content Can Be Sent to an Arbitrary Configured Host
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.
for attempt in range(retries + 1):
try:
resp = requests.post(
f"{MINIMAX_BASE}/image_generation",
headers={
"Authorization": f"Bearer {MINIMAX_API_KEY}",
The code reads OPENAI_BASE from the environment and then sends the OpenAI API key in an Authorization header to that URL. If an attacker can influence environment configuration, the skill will exfiltrate the credential to an arbitrary server, making this a credential-leak/SSRF-style risk rather than a normal API call.
for attempt in range(retries + 1):
try:
resp = requests.post(
f"{OPENAI_BASE}/images/generations",
headers={
"Authorization": f"Bearer {OPENAI_API_KEY}",
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.
for attempt in range(retries + 1):
try:
resp = requests.post(
f"{MINIMAX_BASE}/text_to_speech",
headers={
"Authorization": f"Bearer {MINIMAX_API_KEY}",
As with image generation, OPENAI_BASE is environment-controlled and used as the destination for authenticated requests carrying the OpenAI API key. A maliciously set base URL would cause secret disclosure to an attacker-controlled endpoint and may also send user content off-platform unexpectedly.
for attempt in range(retries + 1):
try:
resp = requests.post(
f"{OPENAI_BASE}/audio/speech",
headers={
"Authorization": f"Bearer {OPENAI_API_KEY}",
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
复制 .env.example 为 .env,填入你的 API Key:
cp .env.example .env
# 编辑 .env 文件
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
cp .env.example .env
# 编辑 .env 文件
或者直接设置环境变量:
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
```bash
cp .env.example .env
# 编辑 .env 文件
```
或者直接设置环境变量:
The generic command runner executes arbitrary strings via the shell, which is a classic tool-parameter abuse sink. Since later call sites construct commands from scene text and subtitle content derived from user input, an attacker can potentially inject shell syntax and execute unintended commands.
def run_cmd(cmd, timeout=120):
"""运行命令,返回 (ok, stdout)"""
try:
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)
return r.returncode == 0, r.stdout.strip()
except subprocess.TimeoutExpired:
return False, "Timeout"
This path invokes an external CLI through the shell using text ultimately derived from the user-provided content. Because the skill is designed to transform arbitrary user topics and points into media, this context makes command injection materially more plausible and dangerous.
The Edge TTS call exposes a direct shell sink reachable by attacker-controlled narration text. The attempted quote escaping is incomplete and brittle, so crafted input can break command boundaries or trigger shell expansions, leading to arbitrary command execution.
# edge-tts 命令行
safe_text = text.replace('"', '\\"').replace("'", "\\'")
cmd = f'edge-tts --voice zh-CN-XiaoxiaoNeural --text "{safe_text}" --write-media "{output_path}"'
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=60)
if result.returncode == 0 and Path(output_path).exists():
size_kb = Path(output_path).stat().st_size / 1024
log(f" 🔊 Edge TTS: {Path(output_path).name} ({size_kb:.0f}KB)")
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
The README instructs users to configure API keys and use third-party AI backends, but it does not clearly warn that user-provided topics, points, prompts, and generated media may be transmitted to external providers. In a content-generation skill, this can expose sensitive business ideas, personal data, or proprietary content to outside services without informed consent.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
| `MINIMAX_API_KEY` | `` | MiniMax API Key |
| `MINIMAX_TTS_VOICE` | `female-yujie` | MiniMax 配音角色 |
| `OPENAI_API_KEY` | `` | OpenAI API Key |
| `OPENAI_BASE` | `https://api.openai.com/v1` | OpenAI API 地址 (可换代理) |
| `OPENAI_TTS_VOICE` | `alloy` | OpenAI 配音: alloy/echo/fable/nova/shimmer |
| `OPENAI_IMAGE_MODEL` | `dall-e-3` | OpenAI 图片模型 |
The skill advertises capabilities that imply environment variable access, disk writes, network calls, and shell/FFmpeg execution, but it declares no explicit tool scope or permission boundaries. In an agent ecosystem, this creates overbroad implicit authority: a user or host may invoke the skill without realizing it can transmit data externally, write arbitrary files, and run commands.
The skill description promotes fully automated image generation, TTS, subtitles, and rendering but does not warn that user-provided content may be sent to an external API and that multiple generated media artifacts will be written to disk. This is dangerous because users may supply sensitive or proprietary content under the false assumption that processing is local and ephemeral.
The description states '中文字幕自动适配', which fixes subtitle output to Chinese. This is a natural-language locale constraint and no opt-in, configuration choice, or region-specific justification is provided elsewhere in the file.
The changelog claims the skill is 'self-contained' and has 'no external dependencies', while the rest of the document clearly requires a MiniMax API key, network access, Python packages, and FFmpeg. This kind of contradictory security disclosure can mislead users and reviewers into underestimating data egress, third-party exposure, and execution requirements.
The file’s natural-language description and usage are entirely in Chinese, and later execution also defaults to a Chinese Edge TTS voice, presenting the skill as Chinese-only behavior. This is a locale/language policy concern because the skill does not document user choice or opt-in for language selection.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY", "")
# MiniMax 配置
MINIMAX_BASE = "https://api.minimaxi.com/v1"
MINIMAX_TTS_VOICE = os.environ.get("MINIMAX_TTS_VOICE", "female-yujie")
# OpenAI 配置
Allowing the API base URL to come from the environment is dangerous in a credentialed client because it changes where secrets and user data are transmitted. In this skill, that configuration directly affects authenticated image and TTS requests, amplifying the impact.
MINIMAX_TTS_VOICE = os.environ.get("MINIMAX_TTS_VOICE", "female-yujie")
# OpenAI 配置
OPENAI_BASE = os.environ.get("OPENAI_BASE", "https://api.openai.com/v1")
OPENAI_TTS_VOICE = os.environ.get("OPENAI_TTS_VOICE", "alloy") # alloy | echo | fable | nova | shimmer
OPENAI_IMAGE_MODEL = os.environ.get("OPENAI_IMAGE_MODEL", "dall-e-3")
The skill has broad shell-execution capability through a generic wrapper, and that wrapper is used with dynamically assembled FFmpeg command strings. In this context, the capability is more dangerous because user content flows into the command construction path, increasing the chance of arbitrary command execution.
The helper uses subprocess.run with shell=True on a string command, and it is later fed FFmpeg commands assembled from user-controlled fields such as topic, title, and script text. Because shell metacharacters are interpreted by the shell, an attacker can inject additional commands and achieve arbitrary command execution on the host running the skill.
def run_cmd(cmd, timeout=120):
"""运行命令,返回 (ok, stdout)"""
try:
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)
return r.returncode == 0, r.stdout.strip()
except subprocess.TimeoutExpired:
return False, "Timeout"
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
for attempt in range(retries + 1):
try:
resp = requests.post(
f"{MINIMAX_BASE}/image_generation",
headers={
"Authorization": f"Bearer {MINIMAX_API_KEY}",
The code downloads a URL returned by the upstream API without validating the scheme, host, or IP destination. If the provider response is compromised or manipulated, this can turn the skill into an SSRF primitive or force downloads from unexpected internal or local addresses.
data = resp.json()
if data.get("base_resp", {}).get("status_code") == 0:
img_url = data["data"]["image_urls"][0]
img_resp = requests.get(img_url, timeout=30)
if img_resp.status_code == 200:
with open(output_path, "wb") as f:
f.write(img_resp.content)
Although outbound transmission is expected, this particular request is dangerous because the destination host is configurable via OPENAI_BASE while carrying a bearer token. That creates a realistic path for secret exfiltration and unauthorized third-party data transfer.
for attempt in range(retries + 1):
try:
resp = requests.post(
f"{OPENAI_BASE}/images/generations",
headers={
"Authorization": f"Bearer {OPENAI_API_KEY}",