T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:46
- Finding
- Shell Command Injection Through an Unquoted User-Controlled Path<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 46-52 **Vulnerability Type**: OS command injection **Risk Level**: Critical ### Vulnerable Code Snippet ```markdown 1. Ask: "What shared path should I use for the family grocery data? (e.g. /Users/Shared/grocery)" 2. Create directory: `mkdir -p [path]` 3. Initialize files from `memory-template.md`: `config.json`, `users.md`, `list.md`, `history.md` 4. Write the current user to `users.md` as `admin` 5. Save path to OpenClaw memory as `family_grocery_path` 6. Confirm: "Setup complete. You are admin. Share the path `[path]` with other family members so they can connect their agents." ``` ### Technical Analysis The initialization procedure instructs the agent to substitute a user-provided path into the shell command `mkdir -p [path]`. It does not require shell avoidance, argument separation, quoting, escaping, path canonicalization, or rejection of shell metacharacters. If the agent follows the instruction by constructing a shell command, shell syntax embedded in the supplied path can be interpreted as an additional command rather than as part of a directory name. Quoting alone would remain fragile if implemented incorrectly; the safe approach is to avoid invoking a shell entirely. ### Attack Path 1. An attacker initiates the first-time setup flow. 2. The skill asks the attacker to provide a shared path. 3. The attacker supplies a path containing shell control syntax, such as a command separator followed by an attacker-selected command. 4. The agent substitutes that value into `mkdir -p [path]`. 5. A shell interprets the injected syntax and executes the additional command with the agent process's privileges. ### Impact Assessment Successful exploitation can provide arbitrary command execution under the account running the agent. Depending on that account's permissions, an attacker could read or modify local files, access credentials available to the process, alter application state, i ...[truncated 103 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not construct or execute a shell command for directory creation. - Use a filesystem API that receives the destination path as one indivisible argument. - Canonicalize the requested path before use and display the resolved path for confirmation. - Restrict storage to a dedicated, application-owned base directory. - Reject paths containing null bytes, control characters, or invalid platform-specific components. - Verify that the resolved path remains beneath the approved base directory. - Add tests covering command separators, substitutions, quoting characters, newlines, and traversal sequences. ]]>
