T09 · Insecure Skill Coding Practices
- Location
SKILL.md:10- Finding
Shell Command Injection Through Prompt Interpolation in the Documented Agent Workflow
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 10-15
Vulnerability Type: Shell command injection
Risk Level: HighVulnerable 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 -vTechnical 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.pyinvokes Ollama safely throughsubprocess.run()with an argument list and withoutshell=True, that protection does not address the outer shell command recommended bySKILL.md. The injection occurs before Python starts, when the Agent's execution tool parses the constructed command.Attack Path
- An attacker submits an image-generation request containing shell metacharacters and a double quote designed to terminate the
--promptargument. - The Agent replaces
<PROMPT>with the attacker-controlled text as instructed bySKILL.md. - The Agent sends the resulting string to a shell-capable execution tool.
- The shell interprets the injected operators or substitutions as commands rather than prompt data.
- 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]
- An attacker submits an image-generation request containing shell metacharacters and a double quote designed to terminate the
- Remediation
View 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.mdto 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.
