T09 · Insecure Skill Coding Practices
- Location
src/video_merger.py:97- Finding
FFmpeg Concat Manifest Injection Through Unescaped Filenames
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This video-merging skill is mostly purpose-aligned, but it has a real unsafe filename-handling flaw and runs system and FFmpeg commands that users should review before use.
Review before installing. Use this only on video directories and filenames you trust, avoid attacker-supplied clip names, choose output paths carefully, and inspect the install script before allowing it to install FFmpeg with sudo or a system package manager.
src/video_merger.py:97FFmpeg Concat Manifest Injection Through Unescaped Filenames
Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.
if command -v brew &> /dev/null; then
brew install ffmpeg
elif command -v apt &> /dev/null; then
sudo apt update && sudo apt install -y ffmpeg
else
echo "请手动安装ffmpeg:https://ffmpeg.org/download.html"
exit 1
The natural-language content and usage guidance are presented only in Chinese, which can amount to forcing a specific language without user opt-in. The policy for this category calls out language or locale constraints unless the skill offers a language choice or clearly justifies a region-specific limitation.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
brew install ffmpeg
sudo apt install ffmpeg
### 2. 安装video-merger
The skill advertises executable installation and script usage, which implies shell and file access, but it does not declare any explicit tool scope or permissions boundaries. This can lead to overbroad execution in agent environments, making it harder to enforce least privilege and increasing the chance of unintended file access or command execution.
The manifest description and main documentation are written entirely in Chinese, which creates an implicit language constraint for users. Under the language/locale policy rule, this is a natural-language policy concern when no opt-in, alternative language, or justification for the locale restriction is provided.
The trigger list is broader than the skill’s actual scope: terms like "video", "merge", and "concat" are generic and can cause the skill to activate for many ordinary video-editing requests beyond segmented short-video merging. Over-broad activation increases the chance of inappropriate routing or unintended execution of file-processing behavior on user media, which is a real security/reliability issue even though the metadata does not show obviously malicious content.
This shell script runs sudo apt update && sudo apt install -y ffmpeg, which changes the system by installing packages and may prompt for elevated privileges. Although the script prints progress messages, it does not clearly warn the user that it will modify the system package state or request confirmation before doing so.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# No external Python dependencies required!
# Only needs ffmpeg installed on system:
# macOS: brew install ffmpeg
# Ubuntu/Debian: sudo apt install ffmpeg
# Windows: Download from https://ffmpeg.org/download.html
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
# No external Python dependencies required!
# Only needs ffmpeg installed on system:
# macOS: brew install ffmpeg
# Ubuntu/Debian: sudo apt install ffmpeg
# Windows: Download from https://ffmpeg.org/download.html
This code file contains natural-language descriptions and user-facing status/error text in Chinese, beginning with the module docstring and constructor docstring, with no indication that language is selectable or that the skill is intended only for a Chinese-speaking context. The policy scope for SQP-3 applies to all file types, including comments, docstrings, and string literals, so this constitutes a locale/language policy issue.
The constructor accepts ffmpeg_path and ffprobe_path and executes them directly. If an untrusted caller can supply these paths, they can cause execution of an arbitrary local binary or script under the privileges of the running process, which is a genuine command-execution risk even without shell=True.
"""检查依赖是否安装"""
for tool in [self.ffmpeg_path, self.ffprobe_path]:
try:
subprocess.run([tool, "-version"], capture_output=True, check=True)
except Exception as e:
raise RuntimeError(f"未找到{tool},请先安装ffmpeg:https://ffmpeg.org/download.html") from e
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
"-of", "default=noprint_wrappers=1:nokey=1",
video_path
]
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
width, height, duration = result.stdout.strip().split("\n")[:3]
return int(width), int(height), float(duration)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
temp_raw
]
print("正在拼接视频片段...")
subprocess.run(cmd_concat, capture_output=True, check=True)
# 获取总时长
_, _, total_duration = self.get_video_info(temp_raw)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
temp_raw
]
print("正在拼接视频片段...")
subprocess.run(cmd_concat, capture_output=True, check=True)
# 获取总时长
_, _, total_duration = self.get_video_info(temp_raw)
The code passes user-influenced values such as resolution, fps, transition_duration, crf, preset, and especially output_path directly into an ffmpeg invocation without validation. While shell injection is avoided, untrusted parameters can still trigger dangerous ffmpeg behaviors such as writing to arbitrary filesystem locations, selecting unintended protocols/devices depending on ffmpeg build/configuration, or causing resource exhaustion through extreme encoding settings.
"-c:a", "aac", "-ar", "44100", "-ac", "2",
output_path
]
subprocess.run(cmd_final, capture_output=True, check=True)
# 验证输出文件
if os.path.exists(output_path) and os.path.getsize(output_path) > 0:
This final ffmpeg encoding step accepts unvalidated parameters and an output path that may be attacker-controlled through the library API. In the context of a video-merging skill, arbitrary output destinations and unconstrained encoding values increase risk of file overwrite, misuse of ffmpeg-supported sinks/protocols, and denial-of-service via expensive transcoding workloads.
"-c:a", "aac", "-ar", "44100", "-ac", "2",
output_path
]
subprocess.run(cmd_final, capture_output=True, check=True)
return True
This markdown file presents its changelog and linked standards entirely in Chinese, which constitutes a natural-language locale choice. The file does not indicate that the Chinese locale is optional or justified as region-specific, so it may violate a language/locale policy requiring user opt-in or explicit documentation.
This markdown file contains policy text only in Chinese and does not offer an alternative language or note that the locale is intentionally region-specific. Under the natural-language policy rule, forcing a specific language without user opt-in can be a policy concern.
This markdown file contains user-facing instructions exclusively in Chinese, including headings and all contribution steps. Under the language/locale policy, forcing a specific language without user opt-in can be a natural-language policy violation unless the locale constraint is explicitly documented and justified.
This markdown file documents a command that creates an output file path but does not mention whether existing files may be overwritten or that running the command will write a new media file to disk. For markdown files, the guidance asks for warnings when behaviour could affect user data or system integrity, and file-writing behavior is described here without any cautionary note.
The manifest description and tags are entirely in Chinese, which suggests the skill is presented in a single language without any stated user opt-in or justification for a locale-specific scope. Under the policy, language constraints should either offer choice or be clearly documented as region-specific.
All user-facing messages in the script are in Chinese, with no opt-in, fallback, or indication that the skill is intended only for Chinese-speaking users. This can violate language/locale policy when a skill imposes a language choice without user selection or documented justification.
This code includes user-facing Chinese-language text in the module docstring and prints errors in Chinese, but does not provide any language or locale selection. That can violate a language/locale policy when users are not explicitly opted into Chinese output.