T09 · Insecure Skill Coding Practices
Error
- Location
- modes/team.sh:321
- Finding
- Arbitrary Local Script Execution Through Template Path Traversal<![CDATA[ ## Vulnerability Details **File Location**: `modes/team.sh:321-324` **Vulnerability Type**: Unvalidated path traversal leading to arbitrary local shell-script execution **Risk Level**: High ### Vulnerable Code ```bash # Get template-specific spawn prompt if [[ -f "$TEMPLATES_DIR/$TEMPLATE.sh" ]]; then SPAWN_PROMPT=$(bash "$TEMPLATES_DIR/$TEMPLATE.sh") else ``` ### Technical Analysis The value of `--template` is accepted without an allowlist or path validation. It is concatenated with the trusted templates directory and the `.sh` suffix, and the resulting file is executed using `bash`. An attacker-controlled value can contain `../` components and escape the intended `templates/` directory. The `-f` check only confirms that the resolved path is a regular file; it does not ensure that the canonical path remains inside the templates directory. Because the file is explicitly passed to `bash`, it does not need to have its executable bit set. It only needs to be readable by the account running the Skill. ### Attack Path 1. The attacker places or identifies a readable shell script outside the `templates/` directory, with a filename ending in `.sh`. 2. The attacker supplies a traversal value such as: ```text --template ../../attacker/payload ``` 3. The constructed path resolves to: ```text <skill-root>/templates/../../attacker/payload.sh ``` 4. The regular-file test succeeds. 5. `bash` executes the attacker-selected script. 6. The script runs with the operating-system privileges and environment of the Skill process. ### Impact Assessment Successful exploitation provides arbitrary command execution as the user running the Skill. This may allow reading or modifying that user's files, accessing inherited environment variables, altering project source code, invoking installed programs, or initiating network connections permitted to that account. The vulnerability does not independently provide root privileges, but its scope includ ...[truncated 55 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Replace dynamic path construction with an explicit identifier-to-file mapping: ```bash case "$TEMPLATE" in parallel-review) TEMPLATE_FILE="$TEMPLATES_DIR/parallel-review.sh" ;; competing-hypotheses) TEMPLATE_FILE="$TEMPLATES_DIR/competing-hypotheses.sh" ;; fullstack-feature) TEMPLATE_FILE="$TEMPLATES_DIR/fullstack-feature.sh" ;; architecture-decision) TEMPLATE_FILE="$TEMPLATES_DIR/architecture-decision.sh" ;; bottleneck-analysis) TEMPLATE_FILE="$TEMPLATES_DIR/bottleneck-analysis.sh" ;; inventory-classification) TEMPLATE_FILE="$TEMPLATES_DIR/inventory-classification.sh" ;; simple-dialog) TEMPLATE_FILE="$TEMPLATES_DIR/simple-dialog.sh" ;; *) echo "Error: unsupported template" exit 1 ;; esac ``` 2. Reject values containing `/`, `\`, `..`, control characters, or shell metacharacters. 3. Canonicalize the selected path and verify that it remains beneath the canonical templates directory. 4. Prefer storing templates as non-executable data files rather than shell scripts when they only emit prompt text. ]]>
