T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:144
- Finding
- Shell command injection through the user-controlled PR title<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 144-146 **Vulnerability Type**: Shell command injection **Risk Level**: High ### Vulnerable Code ```bash gh pr create \ --title "$ARGUMENTS" \ --body "$(cat <<'EOF' ``` ### Technical Analysis The PR title is obtained from the user through `$ARGUMENTS` and inserted directly into a shell command template. The Skill does not require validation, escaping, or transfer through a structured process-argument interface. Although `$ARGUMENTS` appears between double quotes, raw template substitution may occur before the shell parses the command. An attacker can therefore provide a title containing a double quote, command separator, or command substitution expression that terminates the intended argument and introduces another shell command. The permitted tool configuration includes `Bash(gh pr create:*)`, so an injected suffix embedded in an otherwise permitted `gh pr create` invocation could be interpreted by the shell rather than treated exclusively as PR-title text. ### Attack Path 1. An attacker or untrusted user supplies a crafted PR title containing shell syntax, such as a closing quote followed by a command separator. 2. The Skill substitutes the supplied value for `$ARGUMENTS` in the `gh pr create` command. 3. The injected quote terminates the intended `--title` argument. 4. The shell parses the remaining attacker-controlled content as one or more commands. 5. Those commands execute with the operating-system permissions and accessible environment of the Agent process. ### Impact Assessment Successful exploitation can provide arbitrary command execution under the Agent's local account. Depending on that account's permissions and environment, an attacker could: - Read or modify repository files. - Access credentials available to the process, including Git or GitHub authentication material. - Alter source code or Git history. - Create unauthorized commits or pull requests. - Exfilt ...[truncated 226 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not substitute `$ARGUMENTS` directly into shell source. - Pass the PR title through a structured process API where the title is supplied as a discrete argument without an intervening shell. - If the execution environment requires a shell, transfer the title through a safely initialized environment variable and reference it as a single quoted argument. - Reject control characters, newlines, shell metacharacters, and titles exceeding an appropriate maximum length as defense in depth. - Do not attempt to implement shell escaping through ad hoc character replacement. - Add tests using titles containing quotes, semicolons, dollar signs, backticks, command substitutions, newlines, and leading hyphens. - Require explicit user confirmation of the final title after validation and before PR creation. ]]>
