T09 · Insecure Skill Coding Practices
- Location
SKILL.md:42- Finding
Command Injection Through Unvalidated Video Parameters
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 42–44
Vulnerability Type: OS command injection
Risk Level: HighVulnerable Code
bash yt-dlp -P {YOUR_WORKSPACE_DIR}/bilibili/videos -I 1 -o "{BV_ID}.mp4" {video_url}Technical Analysis
The skill instructs the agent to interpolate user-influenced values directly into a Bash command. In particular,
{video_url}is unquoted and is not subject to any documented URL or hostname validation. If the generated command is executed through a shell, shell metacharacters in this value can introduce additional commands, redirections, pipelines, or substitutions.Although
{BV_ID}appears inside double quotes, double quotes do not suppress command substitution such as$()or backtick expansion. Consequently, an unvalidated BV identifier can also become an injection vector.{YOUR_WORKSPACE_DIR}is unquoted, which can cause argument splitting or shell interpretation if the workspace path contains special characters.Even if the process is eventually invoked without a shell, an attacker-controlled value beginning with a hyphen could be interpreted by
yt-dlpas an option unless the end-of-options marker--is used. The instruction therefore lacks both shell-level safety and argument-level validation.Attack Path
- An attacker supplies a crafted value as a Bilibili video URL or BV identifier.
- The agent follows the skill instructions and substitutes that value into the documented Bash command.
- The command is passed to a shell for execution.
- The shell interprets attacker-provided metacharacters or command substitutions rather than treating the entire value as inert data.
- The injected command executes with the same operating-system privileges and environment access as the agent process.
Impact Assessment
Successful exploitation permits arbitrary command execution under the agent's account. The attacker could read or modify ...[truncated 368 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not construct a shell command by concatenating dynamic values. Invoke
yt-dlpthrough a process API that accepts an argument array and disables shell interpretation. - Validate BV identifiers against a strict allowlist pattern before use, accepting only the exact characters and length required by Bilibili identifiers.
- Parse the supplied URL and require an approved HTTPS hostname, such as
www.bilibili.com, rather than relying on string-prefix checks. - Reject embedded credentials, control characters, unexpected ports, URL schemes other than HTTPS, and ambiguous or malformed hostnames.
- Insert
--before the URL argument to prevent option injection. - Resolve the output directory internally and pass it as a single process argument rather than interpolating it into shell text.
- Generate the output filename only from a validated identifier or an application-generated value.
- Run the downloader with minimal filesystem permissions and without unnecessary secrets in its environment.
- Do not construct a shell command by concatenating dynamic values. Invoke
