T09 · Insecure Skill Coding Practices
- Location
SKILL.md:19- Finding
Command Injection Through Unsafe Recipient Interpolation
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 19-24
Vulnerability Type: Command injection through unsafe shell-command construction
Risk Level: HighVulnerable Code
markdown ## Cognitive Directives WHEN [A new email needs to be drafted] THEN [Execute the native terminal command `gog gmail drafts create --to "..." --json`] ## Schema Example ```json { "command": "gog gmail drafts create --to \"example@gmail.com\" --json" }text ### Technical Analysis The skill directs the agent to place a recipient value inside a quoted terminal-command string. It does not require strict email-address validation, shell metacharacter rejection, escaping, or execution through an argument-array API. If recipient data is attacker-controlled, a value containing quotation marks and shell syntax may terminate the intended `--to` argument and introduce additional shell operations. The terminal shell could then interpret those operations as commands rather than recipient data. The retry loop does not mitigate this issue and could cause a malicious input to be attempted repeatedly. ### Attack Path 1. An attacker supplies or influences the email recipient value used by the skill. 2. The agent substitutes that value into the documented `gog gmail drafts create --to "..." --json` command. 3. A maliciously constructed value escapes the quoted argument and introduces shell syntax. 4. The agent executes the resulting command through a terminal shell. 5. The shell runs the injected operation with the same operating-system privileges and environment access as the agent process. ### Impact Assessment Successful exploitation could permit arbitrary local command execution under the agent's account. Depending on that account's privileges and environment, an attacker could read or modify accessible files, obtain locally available credentials or tokens, alter data, invoke other installed tools, or use the co ...[truncated 222 chars]- Remediation
View remediation
Remediation Suggestions
- Invoke
gogthrough a structured process-execution API that accepts an executable and a separate argument array, such as["gmail", "drafts", "create", "--to", recipient, "--json"]. Do not construct a shell command by concatenating user-controlled strings. - Disable shell interpretation when launching the process.
- Parse and validate every recipient with a well-tested email-address parser before execution.
- Reject control characters, unexpected quotation marks, newlines, and shell metacharacters in recipient input.
- If multiple recipients are supported, parse them into individual validated addresses rather than passing an unverified combined string.
- If shell execution is unavoidable, apply platform-appropriate shell escaping after validation; escaping alone should not replace structured argument execution.
- Add tests covering quotation marks, command separators, command substitution syntax, newlines, and malformed email addresses.
- Ensure retry behavior only repeats validated, safely represented arguments and does not re-execute malformed attacker-controlled command strings.
- Invoke
