T09 · Insecure Skill Coding Practices
Error
- Location
SKILL.md:48- Finding
Command Injection Through Unquoted Worktree Paths and Git References
- Content
View full analysis
status --short git -C branch --show-current git -C log --oneline -3 git log "$DEFAULT".. --oneline ``` ```markdown - Remove orphaned worktree (CLEAN): `git worktree remove ` - Merge unmerged commits: `git merge --no-ff` - Cherry-pick specific commits: `git cherry-pick ` - Delete merged branches: `git branch -d ` - Delete stale branches (confirmed discard): `git branch -D ` ``` ### Technical Analysis The Skill instructs the Agent to substitute repository-derived worktree paths, branch names, and commit identifiers directly into shell command templates. These dynamic arguments are not quoted, validated, or separated from command options with `--`. Worktree paths can contain whitespace and shell metacharacters. If the Agent performs direct textual substitution and executes the resulting command through a shell, metacharacters in a maliciously crafted path can terminate or modify the intended Git command and introduce an additional command. This makes command execution possible during the inspection phase, despite the Skill's assertion that scanning is read-only. Git references also require defensive validation and argument handling. Crafted names may cause parsing ambiguity or unexpected option interpretation in commands that do not use `--`. The destructive cleanup commands increase the potential consequences by operating on branches and worktrees selected from repository-controlled state. ### Attack Path 1. An attacker prepares or influences a Git repository containing a worktree whose path includes shell-significant characters, or supplies crafted repository reference data. 2. A user invokes `/recover` against that repository. 3. The Skill e ...[truncated 1309 chars]- Remediation
View remediation
^{commit}'` and use the resolved object ID for subsequent operations. 6. Use `--` to terminate option parsing wherever the relevant Git command supports it. 7. Reject values containing control characters and avoid generating executable cleanup commands by concatenating repository-derived text. 8. Keep inspection and cleanup separate. Display validated targets first, obtain explicit approval for each destructive action, and then execute only the previously validated structured arguments. 9. Add hostile-input tests covering paths with spaces, quotes, command substitutions, semicolons, newlines, and option-like prefixes. ]]>
