T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:42
- Finding
- Shell Command Injection Through Verbatim User-Input Interpolation<![CDATA[ ## Vulnerability Details **File Locations**: - `SKILL.md`, lines 42-43, 54, 63, and 70 - `references/lite-recipes.md`, lines 16 and 29 **Vulnerability Type**: Unsafely constructed shell commands **Risk Level**: Medium ### Complete Vulnerable Snippets `SKILL.md`, lines 42-43: ```text `--query` must preserve the complete original user input without truncation or modification. dws aisearch person --query "<complete value>" --dimension <dimension> --format json ``` `SKILL.md`, line 54: ```shell dws aisearch enterprise --queries "<topic>" --types <document,mail,...> --time-range "<time>" --format json ``` `SKILL.md`, line 63: ```shell dws aisearch behavior --queries "<topic>" --behavior-type <action> --direction <direction> --format json ``` `references/lite-recipes.md`, line 16: ```shell aisearch person --query "<keyword>" --dimension <dimension> ``` `references/lite-recipes.md`, line 29: ```shell contact user search-mobile --mobile "<mobile number>" aisearch person --query "<keyword>" --dimension <dimension> ``` ### Technical Analysis The Skill instructs the agent to place user-controlled names, topics, mobile numbers, time ranges, and interaction directions directly into shell-style command templates. It also requires some values to be preserved verbatim. No corresponding requirement mandates structured argument passing, shell escaping, validation, or rejection of shell metacharacters. Double quotes alone do not safely neutralize shell input. If these generated command strings are passed to a shell, input containing a quote followed by shell operators can escape the intended argument. Command substitutions such as `$()` and backticks may also be evaluated inside double quotes by common shells. For example, a malicious search value could conceptually close the quoted argument, append an unintended command, and comment out the remainder. The exact syntax would depend on the shell and execution interface. The issue is exploitable only when th ...[truncated 1689 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Invoke `dws` through a process API that accepts an executable and an argument array. Each user-controlled value must be passed as a separate argument without invoking a shell. 2. Explicitly prohibit execution through `sh -c`, `bash -c`, `eval`, command substitution, or equivalent string-evaluation mechanisms. 3. Validate fixed-choice parameters against strict allowlists: - `dimension`: documented dimension values only. - `types`: documented content-type values only. - `behavior-type`: documented behavior values only. 4. Treat names, topics, time ranges, directions, and mobile numbers as opaque data rather than command text. 5. If shell execution is unavoidable, use robust platform-specific argument escaping and reject line breaks, unmatched quotes, shell operators, backticks, and command-substitution syntax. 6. Validate exact mobile-number searches against the expected telephone-number format before execution. 7. Add tests using values containing quotes, semicolons, pipes, newlines, backticks, `$()`, redirections, and option-like prefixes to verify that every value remains one literal argument. 8. Update both the primary Skill instructions and the lightweight recipes so that safe structured execution is mandatory and consistent. ]]>
