T09 · Insecure Skill Coding Practices
- Location
SKILL.md:32- Finding
Shell Command Injection Through an Unsanitized Metric Extraction Pattern
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 32-75
Vulnerability Type: Command injection through unsafe shell interpolation
Risk Level: HighVulnerable Code
The following is an English rendering of the relevant instructions:
bash # The run command is supplied as a configuration parameter. <RUN_COMMAND> > run.log 2>&1 # The extraction pattern is inserted inside a shell command. grep "<EXTRACTION_PATTERN>" run.logTechnical Analysis
The skill accepts a user-provided experiment command and metric extraction pattern, then interpolates those values into shell command strings. In particular, placing the extraction pattern between double quotes does not make it safe when the complete command is subsequently interpreted by a shell.
An attacker can include a closing quote followed by shell control operators in the extraction pattern. This terminates the intended
grepargument and appends an arbitrary command. The skill provides no validation, escaping, argument-array execution, or explicit approval of the fully resolved command.The experiment command is intentionally capable of executing shell operations, but the instructions do not establish command allowlists, repository boundaries, or other containment. The metric pattern creates an additional execution path where data presented as a search expression can become executable shell syntax.
Attack Path
- An attacker or untrusted task supplies a malicious metric extraction pattern resembling:
text " run.log; arbitrary-command; # - The agent substitutes the value into the documented command:
bash grep "" run.log; arbitrary-command; #" run.log - The shell interprets the semicolon as a command separator.
arbitrary-commandexecutes with the same operating-system identity and permissions as the agent.- Because evaluation occurs in an autonomous loop, the i ...[truncated 696 chars]
- An attacker or untrusted task supplies a malicious metric extraction pattern resembling:
- Remediation
View remediation
Remediation Suggestions
- Do not construct the
grepoperation through shell-string interpolation. Invoke the executable with a structured argument array, equivalent to:text ["grep", "--", extraction_pattern, "run.log"] - If only simple prefixes or metric names are required, validate patterns against a restrictive allowlist rather than accepting arbitrary regular expressions.
- If a shell is unavoidable, pass user-controlled values as positional parameters instead of embedding them in command text.
- Reject unexpected control characters, command substitutions, newlines, and shell metacharacters.
- Display the exact resolved experiment command and obtain explicit approval before its first execution.
- Run experiments in a sandbox with restricted filesystem access, no unnecessary credentials, limited network access, and bounded process privileges.
- Add tests using quotes, semicolons, command substitutions, newlines, and option-like patterns to verify that every pattern remains a literal argument.
- Do not construct the
