T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:13
- Finding
- Command and Option Injection Through Unvalidated Shell Placeholders<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 13–28 **Vulnerability Type**: Command and option injection **Risk Level**: High ### Vulnerable Code ```bash curl -o /tmp/<filename> <url> cp /tmp/<filename> ~/.openclaw/workspace/ message --channel whatsapp --target <phone> --filePath /home/seekey/.openclaw/workspace/<filename> --message "<caption>" rm /tmp/<filename> ``` ### Technical Analysis The workflow instructs the Agent to interpolate a filename, URL, phone number, and caption directly into shell commands. It does not require structured process arguments, shell escaping, strict validation, or termination of command options with `--`. If these commands are assembled as shell text, metacharacters in an attacker-controlled value can alter command structure and execute additional commands. The quoted caption remains unsafe when interpolated into a shell command because embedded quotes, command substitutions, or other shell syntax can escape or affect the intended argument. Values beginning with `-` can also be interpreted as command-line options, while path separators in the filename can alter the files being accessed. The vulnerability affects all four workflow stages: downloading, copying, sending, and cleanup. ### Attack Path 1. An attacker asks the Agent to send media and supplies a crafted filename, URL, phone number, or caption. 2. The Agent substitutes the supplied value into one of the documented shell command templates. 3. The shell interprets attacker-controlled metacharacters or option prefixes rather than treating the entire value as inert data. 4. An injected command executes with the privileges of the Agent process, or a manipulated option changes the behavior of `curl`, `cp`, `message`, or `rm`. 5. The attacker can consequently access or modify files available to the Agent, cause unintended network requests, delete files, or redirect WhatsApp delivery. ### Impact Assessment Successful exploitation can execute arbi ...[truncated 507 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not construct commands by concatenating user-controlled text into shell strings. 2. Prefer native download, filesystem, and messaging APIs with structured parameters. 3. If a subprocess is necessary, pass an argument array with shell processing disabled. 4. Generate temporary and workspace filenames internally instead of accepting raw filenames from users. 5. Restrict filenames to a conservative allowlist, reject path separators and control characters, and canonicalize paths before use. 6. Validate URLs using a URL parser and permit only required schemes, preferably HTTPS. 7. Validate WhatsApp targets against an explicit international telephone-number format. 8. Treat captions exclusively as data passed through a structured messaging API. 9. Insert `--` before positional filesystem operands where supported to prevent option injection. 10. Verify that all resolved source and destination paths remain inside their intended directories. ]]>
