T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:131
- Finding
- Shell Command Injection Through User-Controlled Calendar Values<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 131-139, 148, and 157-164 **Vulnerability Type**: Shell command injection **Risk Level**: High ### Vulnerable Code ```bash gcalcli --nocolor --calendar "<Cal>" add --noprompt --title "<Title>" --when "<Start>" --duration <minutes> gcalcli --nocolor --calendar "<Cal>" add --noprompt --allday --title "<Title>" --when "<Date>" ``` ```bash echo 'BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT DTSTART;VALUE=DATE:20260308 SUMMARY:Event Title RRULE:FREQ=YEARLY TRANSP:TRANSPARENT END:VEVENT END:VCALENDAR' | gcalcli import --calendar "<Cal>" ``` ```bash gcalcli --nocolor delete --iamaexpert "<query>" <start> <end> ``` ### Technical Analysis The Skill instructs the agent to interpolate conversationally supplied calendar names, event titles, dates, times, durations, and search queries into shell command strings. It does not require argument-array execution, escaping, validation, or another mechanism that prevents shell interpretation. Double quotes do not neutralize all shell syntax. Command substitutions such as `$(command)` and backticks can still execute inside double-quoted arguments. A quotation mark may also terminate the expected argument and introduce shell operators. In the ICS example, event data is placed inside a single-quoted `echo` operand; an apostrophe in generated content can terminate that operand and alter the resulting command. The issue applies when an execution environment passes the constructed command through a shell. If the execution tool uses a direct process API with separately encoded arguments, shell injection would be prevented, but the Skill does not mandate that safer execution model. ### Attack Path 1. An attacker causes the user or agent to process a crafted calendar name, event title, or deletion query. 2. The value includes shell metacharacters or command substitution, such as `$(attacker-command)`. 3. The agent substitutes the value into one of the documented com ...[truncated 713 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Invoke `gcalcli` through a direct process API using a separately encoded argument array; do not concatenate a command string or invoke a shell. - Treat calendar names, titles, queries, and generated ICS fields as untrusted data. - Validate dates, times, and durations against strict formats and numeric bounds. - Supply ICS data directly through the child process's standard input rather than constructing an `echo` pipeline. - Do not rely on double quotes or ad hoc escaping as the primary defense. - If shell execution is unavoidable, use a well-tested platform-specific escaping library and reject unexpected control characters, shell metacharacters, and line breaks. - Add explicit Skill instructions prohibiting shell evaluation of user-controlled calendar data. - Test titles and queries containing apostrophes, quotation marks, dollar signs, backticks, semicolons, pipes, newlines, and command-substitution syntax. ]]>
