T09 · Insecure Skill Coding Practices
Error
- Location
- references/ADVANCED.md:139
- Finding
- Command Injection Through Untrusted Task-List Names<![CDATA[ ## Vulnerability Details **File Location**: `references/ADVANCED.md:139` **Vulnerability Type**: Shell command injection through unsafe interpolation into `bash -c` **Risk Level**: High ### Vulnerable Code ```bash gtasks tasklists view | grep -oP '\[\d+\] \K.*' | xargs -P 4 -I {} bash -c 'gtasks tasks view -l "{}" --format=json > "$(echo {} | tr " " "_").json"' ``` ### Technical Analysis The command parses task-list names and substitutes each name directly into a shell program passed to `bash -c`. Quoting the placeholder as `"{}"` does not make this safe because `xargs` performs textual substitution before the resulting command string is interpreted by Bash. If a task-list name contains shell syntax such as command substitution, backticks, quotation marks, or other metacharacters, that syntax can alter the generated shell program. For example, a list name containing `$(malicious-command)` can cause Bash to execute that command while evaluating the interpolated argument or output filename. Task-list names originate from Google Tasks data and must be treated as untrusted data rather than executable shell source. ### Attack Path 1. An attacker gains a means to influence a task-list title consumed by the user, or convinces the user to create/import a specially crafted title. 2. The title includes shell syntax such as `$(malicious-command)`. 3. The user or Agent runs the documented parallel-export command. 4. `xargs` substitutes the crafted title into the text passed to `bash -c`. 5. Bash parses the inserted syntax and executes the attacker-controlled command with the privileges of the user running the Skill. ### Impact Assessment Successful exploitation permits arbitrary command execution under the current local user account. The attacker could potentially: - Read files accessible to the user, including `~/.gtasks/token.json` and other credentials. - Modify or delete user-owned files. - Access Google Tasks through the authenticated CLI session. ...[truncated 250 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Do not insert task-list names into shell source passed to `bash -c`. Process each title strictly as data and quote every variable expansion: ```bash gtasks tasklists view | grep -oP '\[\d+\] \K.*' | while IFS= read -r list; do safe_name=$(printf '%s' "$list" | sed 's/[^A-Za-z0-9._-]/_/g') gtasks tasks view -l "$list" --format=json > "${safe_name}.json" done ``` Additional hardening should include: 1. Prefer structured output from `gtasks tasklists view`, if supported, instead of parsing human-readable output. 2. Reject empty names and reserved path components such as `.` and `..`. 3. Ensure the sanitized filename cannot contain `/`, path traversal sequences, control characters, or leading option characters. 4. Detect filename collisions after sanitization rather than silently overwriting an existing export. 5. If parallel processing is required, pass values as positional arguments or through a structured scripting language; never splice them into executable shell text. 6. Store exports in a dedicated directory created with restrictive permissions. ]]>
