T09 · Insecure Skill Coding Practices
- Location
scripts/spawn.sh:44- Finding
Shell Command Injection Through Unescaped Task and Agent Arguments
- Content
View full analysis
- Remediation
View remediation
&2 exit 1 ;; esac ``` 2. Do not construct shell command strings from untrusted input. Launch the command through a wrapper that receives the task as a positional argument, or safely serialize every argument with `printf '%q'`. 3. If commands must be typed into a tmux shell, build them from a fixed executable and individually shell-escaped arguments: ```bash printf -v quoted_task '%q' "$TASK" tmux send-keys -t "$SESSION_NAME" \ "claude --dangerously-skip-permissions $quoted_task" Enter ``` 4. Apply the same encoding to text sent through diagnostic `echo` commands, or avoid shell interpretation by using `tmux display-message`. 5. Validate session names against a conservative allowlist, such as `^[A-Za-z0-9_-]+$`, and reject invalid values. 6. Add regression tests using payloads containing command substitutions, semicolons, quotes, redirections, newlines, and backticks. Verify that these values are delivered literally to the selected agent and never executed by the shell. ]]>
