T09 · Insecure Skill Coding Practices
- Location
SKILL.md:31- Finding
Shell Command Injection Through Unvalidated CLI Arguments
- Content
View full analysis
`. ### 1. Create the agent with exec (non-interactive, JSON) Use the **exec** tool to run the OpenClaw CLI. Non-interactive creation **requires** `--workspace` and `--non-interactive`. Before creating, check whether it already exists: ```bash openclaw agents list --json ``` Before running creation, explicitly ask for confirmation, for example: - `I am ready to run: openclaw agents add --workspace ~/.openclaw/workspace- --non-interactive --json. Run it now?` Only execute the command after the user confirms. Create the agent: ```bash openclaw agents add --workspace ~/.openclaw/workspace- --non-interactive --json ``` Optional flags you can add when needed: - `--model ` – default model for this agent. - `--agent-dir ` – agent state dir (default: `~/.openclaw/agents//agent`). - `--bind ` – route a channel to this agent (repeatable). ``` ### Technical Analysis The Skill directs the agent to construct and execute a shell command using an agent name, normalized agent ID, model ID, directory, and channel binding that may originate from user input. It recommends simple names but does not impose a mandatory allowlist, reject shell metacharacters, require shell-safe quoting, or require an execution interface that passes arguments without invoking a shell. The statement that OpenClaw normalizes agent name ...[truncated 1995 chars]- Remediation
View remediation
- --workspace - - --non-interactive - --json ``` 4. If shell execution is unavoidable, apply robust platform-appropriate quoting to every dynamic argument after validation. Do not rely on manual interpolation or user confirmation as the primary defense. 5. Build the workspace path from the validated normalized ID rather than accepting an arbitrary path. Resolve the resulting path and verify that it remains beneath the intended OpenClaw workspace directory. 6. Update the Skill instructions to require displaying the validated executable and each argument separately before confirmation, and abort when validation fails. ]]>
