T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:10
- Finding
- Shell Command Injection Through Prompt Interpolation in the Documented Agent Workflow## Vulnerability Details **File Location**: `SKILL.md`, lines 10-15 **Vulnerability Type**: Shell command injection **Risk Level**: High **Vulnerable Code**: ```bash Exécuter via `exec` avec **pty=true** (obligatoire) : ```bash python3 /Users/openclaw/.openclaw/skills/ollama-x-z-image-turbo/runner.py \ --prompt "<PROMPT>" \ --width 1024 --height 1024 --steps 20 \ --out /Users/openclaw/.openclaw/workspace/tmp/ollama_image.png -v ``` ### Technical Analysis The Skill instructs the Agent to insert an untrusted, user-supplied image prompt directly into a shell command. Wrapping the placeholder in double quotes does not provide adequate shell escaping. A prompt containing a double quote can terminate the intended argument, after which shell operators or substitutions can be interpreted by the command processor. Although `runner.py` invokes Ollama safely through `subprocess.run()` with an argument list and without `shell=True`, that protection does not address the outer shell command recommended by `SKILL.md`. The injection occurs before Python starts, when the Agent's execution tool parses the constructed command. ### Attack Path 1. An attacker submits an image-generation request containing shell metacharacters and a double quote designed to terminate the `--prompt` argument. 2. The Agent replaces `<PROMPT>` with the attacker-controlled text as instructed by `SKILL.md`. 3. The Agent sends the resulting string to a shell-capable execution tool. 4. The shell interprets the injected operators or substitutions as commands rather than prompt data. 5. The injected command executes with the operating-system privileges and environment available to the Agent process. ### Impact Assessment Successful exploitation could provide arbitrary command execution under the Agent's account. The attacker could access files readable or writable by that account, modify workspace or Skill content, invoke locally availa ...[truncated 206 chars]
- Remediation
- ## Remediation Suggestions - Do not build a shell command by interpolating the prompt into a command string. - Invoke the Python executable through a structured argument-array interface, passing the entire prompt as one argument without shell parsing. - If the execution environment cannot accept argument arrays, pass the prompt through standard input or a securely created data file. - If shell execution is unavoidable, apply a platform-appropriate escaping function to every dynamic argument. Manual wrapping with quotes is not sufficient. - Update `SKILL.md` to prescribe a structured tool invocation rather than a copyable shell template. - Run the image generator with least privilege and without access to unrelated credentials or sensitive directories.
