T09 · Insecure Skill Coding Practices
- Location
assets/script-template-ai-prompt.md:100- Finding
Shell Command Injection Through Unescaped Generated Prompt Interpolation
- Content
View full analysis
Vulnerability Details
File Location:
assets/script-template-ai-prompt.md:100-104
Vulnerability Type: Shell command injection
Risk Level: HighVulnerable Code
bash python3 "$SKILL_PATH/scripts/videogen.py" "{完整视频生成提示词}" --ratio {9:16或16:9} --resolution 1080p --duration {8/10/12/15} --no-audio --prefix cinematic -o ~/Downloads/QoderVideosA substantially equivalent command also appears in
references/ai-prompts.md:328-332.Technical Analysis
The command interpolates an Agent-generated video prompt directly into a shell command inside double quotes. The generated prompt is derived from user-supplied scene descriptions or uploaded-image analysis. No escaping, argument-array construction, or validation boundary is specified before execution.
Double quotes do not make arbitrary data safe for shell evaluation. If attacker-controlled content introduces a double quote followed by shell syntax, it can terminate the intended argument and append another command. Command substitutions such as
$()and backticks may also be evaluated inside double-quoted shell arguments if preserved in the generated text.The vulnerability is exploitable when the Agent renders the template into a command string and executes it through a shell. Passing arguments directly to a process API without a shell would prevent this interpretation, but the Skill explicitly presents a Bash command rather than a safe argument-array invocation.
Attack Path
- An attacker submits a scene description containing shell metacharacters, command substitution, or a quote-breaking payload.
- The Skill incorporates that description into the generated video prompt.
- The Agent substitutes the complete prompt into the documented Bash command.
- The resulting string is executed through a shell.
- The shell interprets the injected syntax as commands rather than as part of the video prompt.
- The injected commands execute with the pe ...[truncated 594 chars]
- Remediation
View remediation
Remediation Suggestions
- Never construct an executable shell command by interpolating the generated prompt.
- Invoke the video generator with an argument array and with shell processing disabled. For example, use Python's
subprocess.run([...], shell=False, check=True). - Pass large prompts through standard input or a securely created prompt file rather than embedding them in a command string.
- Validate
ratio,resolution, anddurationagainst strict allowlists. - Resolve the output directory to an approved base directory and reject path traversal or unexpected absolute paths.
- Treat all generated prompt text as untrusted, even when it was transformed by the Agent.
- Add regression tests using quotes, semicolons, command substitution, backticks, newlines, and redirection operators.
