T09 · Insecure Skill Coding Practices
- Location
index.ts:17- Finding
Shell Command Injection Through Unescaped Skill Input
- Content
View full analysis
{ exec(`"${path}" ${args.join(" ")}`, { maxBuffer: 1024 * 1024 }, (error, stdout, stderr) => { ``` ### Technical Analysis The Skill reads `action`, `repo`, `message`, `files`, `branch`, and `from` from the invocation input and inserts them directly into a command string. `child_process.exec` evaluates that string through a system shell. Joining arguments with spaces does not preserve argument boundaries or neutralize shell syntax. An attacker who can influence any forwarded string can include command separators, command substitutions, redirections, pipes, or other shell metacharacters. For example, a commit message containing `x; id; #` would place an additional command in the generated shell command. The vulnerability exists before the external Git Manager program receives the arguments. Consequently, safety checks implemented by that program—such as protected-branch enforcement or dry-run behavior—cannot prevent exploitation. ### Attack Path 1. An attacker supplies a crafted Skill input in a field such as `message`, `repo`, `branch`, `from`, `action`, or an element of `files`. 2. The Skill appends ...[truncated 1256 chars]- Remediation
View remediation
{ // Handle the result. } ); ``` 2. Enforce an allowlist of supported actions, such as `status`, `commit`, `push`, `pull`, `branch`, `checkout`, `merge`, `stash`, `log`, and `diff`. 3. Validate repository paths against authorized workspace roots and resolve them canonically before use. 4. Validate branch names with Git-compatible rules and reject control characters, null bytes, and unexpected options. 5. Treat each file as an independent argument rather than combining file names into a comma-delimited string. 6. Insert `--` before file operands where supported to prevent file names from being interpreted as command options. 7. Apply authorization and protected-branch checks in the audited entry point rather than relying exclusively on a downstream executable. 8. Add automated tests using shell metacharacters and command-substitution payloads to verify that inputs remain literal arguments. ]]>
