T09 · Insecure Skill Coding Practices
- Location
scripts/poll-status.sh:21- Finding
Arbitrary Command Execution Through Shell eval
- Content
View full analysis
&2 exit 2 ;; esac done out=$(eval "$cmd" 2>&1 || true) ``` ### Technical Analysis The script accepts a command as a single string through `--cmd` and passes it to `eval`. Unlike direct execution of an argument array, `eval` reparses shell metacharacters, command substitutions, pipelines, redirections, and command separators. Consequently, any untrusted value incorporated into `--cmd` can change the intended probe into arbitrary shell commands. Quoting at the caller is not a reliable security boundary because `eval` performs another shell-parsing pass. ### Attack Path 1. An automated deployment workflow constructs the polling command from repository-controlled or user-controlled metadata. 2. An attacker supplies a value containing shell syntax, such as `;`, `$()`, backticks, or output redirection. 3. The resulting value is passed to `poll-status.sh --cmd`. 4. Line 47 reparses the string through `eval`. 5. The injected command executes with the same local privileges and environment as the deployment agent. ### Impact Assessment Successful exploitation permits arbitrary command execution on the deployment host. Depending on the invoking environment, an attacker may: - Read source code, local files, environment variables, and CLI configuration. - Access Volcengine credentials available to the agent. - Modify deployment state or generated infrastructure configuration. - Invoke cloud APIs using the agent's permissions. - Establish additional local or remote exec ...[truncated 21 chars]- Remediation
View remediation
&2 exit 2 fi out=$("${cmd[@]}" 2>&1 || true) ``` Additional hardening should include: 1. Validate `interval` and `max_attempts` as bounded positive integers. 2. Avoid constructing command strings from repository metadata. 3. Use dedicated polling functions for known Volcengine APIs where possible. 4. Run probes with the minimum environment and privileges required. ]]>
