T09 · Insecure Skill Coding Practices
- Location
scripts/cooldown.sh:10- Finding
Arbitrary Command Execution Through Shell eval
- Content
View full analysis
"$TIMESTAMP_FILE" echo "✅ Success. Timestamp updated." else echo "❌ Command failed. Timestamp NOT updated." exit 1 fi ``` ### Technical Analysis The wrapper combines all command arguments into a single string with `COMMAND="$@"` and subsequently executes that string through `eval`. This causes shell syntax contained in any argument to be parsed a second time. Consequently, characters such as semicolons, command substitutions, redirections, pipes, and logical operators are interpreted as shell syntax rather than remaining literal command arguments. This is especially dangerous if a caller constructs any part of the wrapped command from task definitions, model output, filenames, URLs, or other untrusted input. Using a shell wrapper to invoke a command is consistent with the declared cooldown functionality, but reparsing the command through `eval` is unnecessary and exceeds the execution behavior needed by that functionality. ### Attack Path 1. An attacker obtains control over an argument passed to `cooldown.sh`, directly or through an application that constructs the wrapped command from untrusted data. 2. The attacker supplies an argument containing shell syntax, for example: ```bash ./scripts/cooldown.sh demo 0 'printf safe; id > /tmp/injected' ``` 3. The script flattens the supplied arguments into `COMMAND`. 4. `eval "$COMMAND"` reparses the injected metacharacters. 5. Both the intended command and the injected command execute. ### Impact Assessment Successful exploitat ...[truncated 544 chars]- Remediation
View remediation
"$TIMESTAMP_FILE" echo "Success. Timestamp updated." else echo "Command failed. Timestamp not updated." exit 1 fi ``` Additional hardening should include: - Never use `eval` for command arguments. - Do not concatenate command arguments into a string. - If only specific programs are expected, enforce an allowlist of executable names. - Ensure callers do not pass model-generated or user-controlled executable names without validation. - Run externally triggered workflows under a dedicated, minimally privileged operating-system account. ]]>
