T09 · Insecure Skill Coding Practices
- Location
SKILL.md:128- Finding
Shell Command Injection Through Unvalidated Audit Parameters
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 128–185 and 212–216
Vulnerability Type: Shell command injection
Risk Level: MediumVulnerable Code
bash # Get merge-base of two branches git merge-base origin/<source-branch> origin/<target-branch> # Get all commits on source branch for the target module git log <start-commit>..origin/<source-branch> --oneline --no-merges -- <module-path-1> <module-path-2> ... # Search using user-provided or expanded terms git log <start>..<source> --oneline --no-merges --grep="<keyword>" git log <start>..<source> --oneline --no-merges --grep="<variant1>" git log <start>..<source> --oneline --no-merges --grep="<variant2>" # Filter using user-provided author and date values git log <start>..<source> --oneline --no-merges --author="<author>" --since="<start-date>" --until="<end-date>" # Search using an issue identifier git log <start>..<source> --oneline --no-merges --grep="<issue-id>" # Search paths derived from commits or repository analysis git log <start>..<source> --oneline --no-merges -- <file1> <file2> ... git log <start>..<source> --oneline --no-merges -- <referencing-files> # Iterate over a dynamically constructed commit list for sha in <commit-list>; do all_files=$(git diff-tree --no-commit-id -r --name-only "$sha") external_files=$(echo "$all_files" | grep -v "^<module-path-pattern>") if [ -n "$external_files" ]; then echo "=== $sha ===" echo "$external_files" fi doneTechnical Analysis
The skill instructs an agent to substitute user-controlled or repository-derived values directly into shell command templates. Relevant inputs include branch names, revisions, module paths, keywords, authors, dates, issue identifiers, file lists, regular-expression patterns, and commit lists.
Several placeholders are unquoted. Values placed inside double quotes also remain vulnerable to shell command substitution, such as
$(command)and backticks, if commands ...[truncated 2234 chars]- Remediation
View remediation
Remediation Suggestions
-
Avoid shell command construction
- Invoke Git through an argument-vector process API with shell evaluation disabled.
- Pass every revision, search term, date, and path as a separate argument.
- Do not concatenate user input into command strings.
-
Validate revisions and branch names
- Validate branch names with
git check-ref-format --branch. - Resolve and validate revisions with
git rev-parse --verify. - If raw commit IDs are required, enforce the expected hexadecimal length and verify that each object exists and has the required type.
- Reject control characters, newlines, NUL bytes, and shell metacharacters.
- Validate branch names with
-
Handle collections safely
- Store commits and paths in arrays rather than space-delimited strings.
- Iterate over validated array elements.
- For shell implementations, use forms such as
for sha in "${commits[@]}"; never inject a textual list into shell source.
-
Protect path processing
- Preserve the
--separator before path arguments. - Pass each path as an individual argument.
- Use NUL-delimited Git output where filenames are parsed, such as
git diff-tree -z, because repository filenames may contain spaces or newlines.
- Preserve the
-
Treat patterns as data
- Pass
--grep,--author, and similar values directly through an argv API. - When literal rather than regular-expression matching is intended, escape the value for the target matching engine or use fixed-string matching where supported.
- Do not rely on double quotes as protection against command substitution in dynamically evaluated shell text.
- Pass
-
Constrain execution privileges
- Run audits in a restricted sandbox with minimal filesystem and network access.
- Avoid exposing unrelated credentials or sensitive environment variables.
- Use a clean, disposable working tree when processing repositories supplied by untrusted parties.
-
Document secure implementation requirements
...[truncated 332 chars]
-
