T09 · Insecure Skill Coding Practices
- Location
SKILL.md:19- Finding
Shell Command Injection Through Unescaped Email Fields
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 19-26
Vulnerability Type: Shell command injection caused by unsafe command construction
Risk Level: HighThe skill directs the agent to interpolate recipient, subject, and body values into a shell command without requiring validation, shell-safe escaping, or a structured argument array.
Complete vulnerable code snippet:
markdown ## Cognitive Directives WHEN [An email needs to be sent to one or more recipients] THEN [Execute the native terminal command `gog gmail send --to "..." --subject "..." --body "..."`] ## Schema Example ```json { "command": "gog gmail send --to \"example@gmail.com\" --subject \"Invoice\" --body \"Please find the invoice attached.\" --json" }text ### Technical Analysis The documented pattern constructs a terminal command by placing email fields inside double-quoted shell arguments. Double quotes do not neutralize every shell operation: command substitutions such as `$(...)` and backtick substitutions may still be evaluated by a shell. An input containing a closing quote can also escape the intended argument and introduce command separators or redirections. For example, if an untrusted body containing `$(id)` is inserted into the documented template and the resulting string is executed through a shell, the shell may run `id` before invoking `gog`. A value that closes the surrounding quote could similarly append an unrelated command. The skill provides no instruction to reject such input or avoid shell interpretation. Exploitability depends on the agent or terminal executing the generated command through a shell rather than invoking `gog` directly with a structured argument list. ### Attack Path 1. An attacker supplies or influences an email recipient, subject, or body that the agent is asked to send. 2. The value includes shell syntax, such as command substitution or a quote followed by a command separato ...[truncated 1122 chars]- Remediation
View remediation
Remediation Suggestions
-
Invoke
gogdirectly through a process API using a structured argument array, for example:text ["gog", "gmail", "send", "--to", recipient, "--subject", subject, "--body", body, "--json"]Explicitly disable shell execution.
-
Revise the skill directive to prohibit constructing a shell command by string interpolation and to require arguments to be passed separately.
-
If only a shell-based interface is available, apply robust escaping designed for the exact target shell. Do not rely solely on surrounding values with double quotes.
-
Validate recipient addresses and reject unexpected control characters. Treat subject and body content as untrusted data rather than executable command text.
-
Require the agent to display and confirm the final recipients and message content before sending, particularly when those fields originate from external or untrusted sources.
-
Prefer passing long or complex message bodies through a safe standard-input or file-based option supported by
gog, while creating any temporary file with restrictive permissions and deleting it after use.
-
