T09 · Insecure Skill Coding Practices
Error
- Location
- skill.md:116
- Finding
- Command Injection Through Unvalidated User-Controlled Arguments<![CDATA[ ## Vulnerability Details **File Location**: `skill.md`, lines 116-123 **Vulnerability Type**: Shell command injection through unsafe argument interpolation **Risk Level**: High ### Vulnerable Code ```markdown 1. **Parse args** → extract video path/URL, options 2. **Download remote video** (if URL): `yt-dlp "URL" -o /tmp/verging-video-enhancement/input.mp4` 3. **Get duration** → `ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 video.mp4` 4. **Trim if needed** (--start/--end or duration > 30s): ```bash ffmpeg -i input.mp4 -ss <start> -to <end> -c:v libx264 -c:a aac /tmp/verging-video-enhancement/trimmed.mp4 ``` ``` ### Technical Analysis The Skill instructs an agent to parse user-supplied video URLs, file paths, start times, and end times and insert them into shell commands. It does not require strict numeric validation for `--start` or `--end`, canonical path validation, URL validation, or process execution through a shell-free argument array. The `<start>` and `<end>` substitutions are shown without quoting. If an implementation constructs a command string according to this documentation and invokes it through a shell, shell control characters in either value can terminate or alter the `ffmpeg` command. Although the URL placeholder is surrounded by double quotes, quoting alone is not a complete security boundary when a value can contain embedded quotation marks, command substitutions, or other shell-significant syntax. The local video path is likewise user-controlled but the documented flow does not define safe handling for it. The vulnerability is conditional on the agent or runtime implementing these documented commands by interpolating arguments into a shell command, which is the execution model implied by the examples. ### Attack Path 1. An attacker invokes the Skill and supplies a crafted value through `--start`, `--end`, `--video`, or a maliciously formed URL. 2. The Skill parses the value w ...[truncated 1073 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse `--start` and `--end` using a strict numeric parser. Reject non-finite, negative, malformed, and out-of-range values. 2. Enforce `0 <= start < end <= 30` after parsing. 3. Do not concatenate user input into shell command strings. Invoke `yt-dlp`, `ffprobe`, and `ffmpeg` through APIs that accept explicit argument arrays with shell execution disabled. 4. Accept only explicitly supported URL schemes, such as HTTPS, and validate remote hostnames against a documented allowlist if only YouTube and Bilibili are supported. 5. Canonicalize local paths and apply a defined file-access policy before processing them. 6. Insert `--` before positional filenames where supported so filenames beginning with a hyphen cannot be interpreted as options. 7. Reject control characters, null bytes, and unexpected shell syntax as defense in depth. 8. Add tests using malicious quotation marks, command substitutions, separators, option-like filenames, malformed numeric values, and Unicode edge cases. ]]>
