T09 · Insecure Skill Coding Practices
- Location
SKILL.md:38- Finding
Shell Command Injection Through Unsafely Interpolated Placeholders
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 38, 42, and 69
Vulnerability Type: Shell command injection
Risk Level: MediumVulnerable Code
bash # Line 38 git log --oneline --all --grep="<keyword>" | head -20 # Line 42 git log -p --all -S '<package-name>' -- package.json | head -40 # Line 69 grep -rc "<framework-import>" --include="*.{ts,js,py,go}" . 2>/dev/null | sort -t: -k2 -rn | head -10Technical Analysis
The Skill directs an Agent to substitute values derived from a conversation or repository into shell command templates. It does not require validation, shell-safe escaping, or invocation through an API that passes arguments without a shell.
The double-quoted placeholders on lines 38 and 69 remain vulnerable to shell expansions such as command substitution using
$(...)or backticks. The single-quoted placeholder on line 42 can become unsafe if an attacker-controlled value contains a single quote that terminates the quoted argument, followed by shell operators and additional commands.The vulnerability is conditional upon the Agent implementing these placeholders through direct textual interpolation and executing the resulting command through a shell. The file contains no embedded malicious payload, but its documented execution pattern can turn untrusted input into executable shell syntax.
Attack Path
- An attacker introduces a crafted keyword, package name, or framework import value into the conversation or a repository artifact that the Agent analyzes.
- The Agent extracts that value while following the Skill's analysis procedure.
- The Agent substitutes the value directly into one of the documented shell command templates.
- The resulting command is executed through a shell without robust argument separation or escaping.
- Shell metacharacters, command substitutions, or broken quoting in the supplied value cause attacker-selected commands to execute.
- Those commands run wit ...[truncated 1136 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not construct shell commands by replacing placeholders in command strings.
- Invoke programs through an execution API that accepts an executable and an argument array without using a shell. For example, pass the search value as a distinct argument to
gitorgrep. - Treat all values obtained from conversations, repository contents, commit messages, dependency metadata, and documentation as untrusted.
- If shell execution is unavoidable, apply a proven shell-quoting routine appropriate to the exact shell rather than manually adding quotation marks.
- Reject control characters and unexpected shell metacharacters. Where practical, constrain keywords, package names, and import identifiers to an explicit allowlist of expected characters.
- Use explicit option termination or pattern operands where supported, such as
--orgrep -e, to prevent values beginning with a hyphen from being interpreted as options. - Update the Skill instructions to state that placeholders are conceptual and must never be interpolated directly into shell source.
- Add adversarial tests covering values containing single quotes, double quotes, backticks,
$(), semicolons, newlines, pipes, redirection operators, and leading hyphens.
