T09 · Insecure Skill Coding Practices
- Location
transitions.md:255- Finding
Shell Command Injection in Multi-Clip Transition Generators
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is a coherent video-editing helper, but it includes unsafe command-building examples, an overwrite-prone export script, and broad system-level install instructions that users should review before installing.
Install only in an isolated environment such as a container or virtual machine. Review generated ffmpeg commands before running them, avoid untrusted or unusual filenames, use safe output names without slashes or traversal, and prefer a virtual environment with pinned dependencies instead of system-wide pip installs.
transitions.md:255Shell Command Injection in Multi-Clip Transition Generators
references/beat-sync.md:129Shell Command Injection in Beat-Sync Assembly Generator
scripts/batch-export.sh:23Output-Name Path Traversal and Forced File Overwrite
scripts/scene-detect.py:167Unsafe Shell Commands Emitted from User-Controlled Video Paths
SKILL.md:25Unpinned System-Wide Dependency Installation
The trigger text is extremely broad and matches many ordinary media-editing requests, causing this shell-capable skill to activate in situations where safer or narrower skills might be more appropriate. Because the skill also directs execution of local scripts and package installers, over-triggering materially increases the chance of unintended command execution on untrusted user-supplied media.
The Python example constructs a shell command by interpolating file paths and filter content into a single string and executes it with shell=True. If any input-derived value such as source filenames, music_file, or output_file contains shell metacharacters, an attacker could inject additional commands, leading to arbitrary command execution.
f"-c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p -r 30 " f"-c:a aac -ar 44100 -ac 2 -movflags +faststart {output_file}" ) subprocess.run(cmd, shell=True)
---
Using subprocess.run(cmd, shell=True) on a command string containing interpolated variables is a classic command-injection sink. An attacker who can influence clip names or other command fragments could execute arbitrary commands on the host, potentially leading to data loss, credential exposure, or full environment compromise.
fc = "\n".join(fc_parts).rstrip(";") cmd = f'ffmpeg {inputs} -filter_complex "{fc}" -map "[vout]" -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p -r 30 -movflags +faststart output.mp4' subprocess.run(cmd, shell=True)
---
subprocess.run(cmd, shell=True) is a direct command-execution sink. Because the command string is assembled from variables including input filenames, an attacker who can influence those values may achieve arbitrary command execution on the host running the skill or copied script.
fc = "\n".join(fc_parts).rstrip(";") cmd = f'ffmpeg {inputs} -filter_complex "{fc}" -map "[vout]" -c:v libx264 -preset slow -crf 18 -pix_fmt yuv420p -r 30 -movflags +faststart output.mp4' subprocess.run(cmd, shell=True)
---
The skill instructs the agent to run shell commands such as apt-get, pip, python, bash, ffmpeg, and ffprobe, but it declares no explicit tool scope or permission boundary. That means a broadly triggered skill could cause powerful command execution without a clear least-privilege contract, increasing the risk of unintended package installation, script execution, or processing of attacker-controlled files.
The document provides a strobe/flash animation snippet that rapidly drives frames to full white without any accompanying safety warning about photosensitive seizure risk or viewer discomfort. In a social-video creation skill, this omission is more dangerous because the content is explicitly intended for broad public distribution on platforms where creators may use the effect without understanding health risks.
The Python example constructs a shell command by interpolating filenames directly into a single command string and then executes it through the shell. If any clip filename is user-controlled, shell metacharacters can break out of the intended ffmpeg invocation and execute arbitrary OS commands, which is especially dangerous in a media-editing skill that commonly processes uploaded files.
The example executes a shell command derived from filenames without warning that untrusted filenames are unsafe, increasing the likelihood that downstream developers will copy the pattern into production. Because this skill is designed for end-user video composition, filenames and paths are plausibly influenced by uploads or project metadata, making command injection a realistic risk.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def extract_audio(input_path: str, tmp_audio: str) -> str:
"""Extract audio from video file to wav for analysis."""
subprocess.run(
["ffmpeg", "-i", input_path, "-ac", "1", "-ar", "22050",
"-y", tmp_audio],
capture_output=True
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
Less accurate than librosa but requires no Python packages.
"""
# Get audio stats over time (100ms chunks)
result = subprocess.run(
["ffmpeg", "-i", audio_path,
"-af", "astats=metadata=1:reset=1",
"-f", "null", "-"],
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def get_video_duration(video_path: str) -> float:
"""Get video duration in seconds using ffprobe."""
result = subprocess.run(
["ffprobe", "-v", "quiet", "-print_format", "json",
"-show_entries", "format=duration", video_path],
capture_output=True, text=True
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def detect_scene_changes(video_path: str, threshold: float) -> list[float]:
"""Use ffmpeg scdet filter to find scene change timestamps."""
result = subprocess.run(
["ffmpeg", "-i", video_path,
"-vf", f"scdet=threshold={threshold}",
"-an", "-f", "null", "-"],
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
frame_path = os.path.join(tmpdir, f"frame_{timestamp:.3f}.jpg")
# Extract frame
subprocess.run(
["ffmpeg", "-ss", str(timestamp), "-i", video_path,
"-vframes", "1", "-q:v", "2", "-y", frame_path],
capture_output=True
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
for i, m in enumerate(moments):
t = m["timestamp"]
out_path = os.path.join(output_dir, f"moment_{i+1:02d}_t{t:.1f}s.jpg")
subprocess.run(
["ffmpeg", "-ss", str(t), "-i", video_path,
"-vframes", "1", "-q:v", "2", "-y",
"-vf", "scale=540:960", out_path],
The Python example both executes a shell command and omits any warning that it should not be used with untrusted filenames or user-controlled values. In this skill context, users are likely to upload arbitrary media files, so documentation that normalizes unsafe shell execution patterns increases the chance of accidental command injection in downstream use.
The embedded Python example constructs a shell command string from clip filenames and other variables, then executes it with subprocess.run(..., shell=True). If any clip name or transition-related value is influenced by untrusted input, shell metacharacters can break out of the ffmpeg command and execute arbitrary OS commands, which is especially risky in an agent skill that may process user-supplied media paths or filenames.
This markdown file includes an apt-get install -y command that changes the host system by installing packages, but the surrounding text does not warn the user that it will modify system state or may require elevated privileges. Under the markdown-file criteria for missing user warnings, system-affecting behavior should be disclosed when it can impact system integrity.
This markdown file includes executable example code that produces a file at /mnt/user-data/outputs/beat_reel.mp4 and runs ffmpeg to create that output, but the surrounding text does not warn that it will write to disk or potentially overwrite an existing file depending on ffmpeg behavior and flags. For markdown files, SQP-2 applies when descriptions omit warnings about behaviors that could affect user data or system state.
This markdown file includes an apt-get install -y command that modifies the host system by installing packages, but the surrounding text does not warn that it changes system state or may require elevated privileges. For markdown files, safety-affecting behavior should be disclosed when it can impact system integrity.
This markdown file provides direct ffmpeg command examples that read and write local media files, but it does not include any warning that users should verify input/output paths or expect files to be created or overwritten depending on their ffmpeg flags. Because SQP-2 applies to markdown files when potentially impactful behavior is undocumented, a brief disclosure would improve safety.