T09 · Insecure Skill Coding Practices
- Location
SKILL.md:193- Finding
Shell Command Injection Through an Untrusted Repository Search Query
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 193
Vulnerability Type: Shell command injection caused by unsafe interpolation of context-derived input
Risk Level: MediumVulnerable Code
bash gh search repos "[targeted query from table above]" --sort stars --limit 10 2>/dev/nullTechnical Analysis
The Skill instructs the Agent to construct a shell command by replacing the quoted placeholder with a targeted query derived from project context or user input. Placing an untrusted value inside double quotes does not make it safe for shell evaluation. Bash still evaluates command substitutions such as
$(command)and backtick expressions inside double-quoted strings.If the Agent copies attacker-controlled project text or a user-provided research target into this template without strict validation, embedded shell syntax may be evaluated by Bash. The resulting command would execute under the same operating-system identity and permissions as the Agent process.
This is an insecure command-construction pattern rather than evidence that the Skill intentionally executes a malicious payload. Exploitation depends on untrusted content being transferred into the query and then passed to Bash as shell source.
Attack Path
- An attacker places a crafted domain, feature name, or research instruction in project context read during Phase 0, or supplies it as the requested scouting target.
- The crafted value contains shell substitution syntax, such as
$(malicious_command). - The Agent derives the targeted repository-search query from that value.
- The Agent replaces the placeholder in the documented command with the crafted query.
- Bash parses the generated command and evaluates the embedded substitution despite the surrounding double quotes.
- The injected command executes with the Agent process's local permissions before or while
gh search reposruns.
Impact Assessment
Successf ...[truncated 744 chars]
- Remediation
View remediation
Remediation Suggestions
-
Do not construct executable shell source by inserting context-derived or user-controlled text into a command template.
-
Prefer a structured GitHub or API tool that accepts the search query as a distinct argument without invoking a shell.
-
If Bash is unavoidable, pass the query through a positional parameter rather than generating a command string. For example:
bash query="$1" gh search repos "$query" --sort stars --limit 10The surrounding harness must pass the value directly as an argument and must not build or execute the command through
eval,bash -c, or equivalent reparsing mechanisms. -
Validate generated search queries against a strict allowlist appropriate for repository searches. Reject shell metacharacters, control characters, command-substitution syntax, and unexpected newlines.
-
Explicitly instruct the Agent to treat README content, planning documents, user-provided targets, repository text, and web results as untrusted data.
-
Avoid suppressing all standard error output with
2>/dev/null, because doing so can conceal malformed commands and hinder detection. Capture and report errors safely instead. -
Add adversarial tests covering values containing
$(...), backticks, quotes, semicolons, newlines, redirections, and shell operators to confirm that they remain inert arguments.
-
