T09 · Insecure Skill Coding Practices
- Location
scripts/setup_channel.py:173- Finding
Shell Command Injection Through Printed Gateway Configuration Command
- Content
View full analysis
Dict[str, Any]: """Build gateway config patch for the channel.""" return { "channels": { "discord": { "guilds": { guild_id: { "channels": { channel_id: { "allow": True, "requireMention": False, "systemPrompt": context } } } } } } } ``` ```python print(f"\nopenclaw gateway config.patch --raw '{json.dumps(patch)}'") ``` ### Technical Analysis The user-controlled `--context` value is inserted into a JSON object and then printed inside a single-quoted shell argument. JSON encoding does not escape characters according to shell quoting rules. In particular, an apostrophe in `context` remains capable of terminating the shell's single-quoted argument. Although the script does not execute the generated command itself, its documented workflow explicitly instructs the operator to copy and execute that command. A crafted context can therefore append arbitrary shell syntax to the displayed command. ### Attack Path 1. An attacker supplies or recommends a crafted `--context` value containing an apostrophe followed by shell metacharacters and an attacker-selected command. 2. The script incorporates that value into `systemPrompt`. 3. The script prints the resulting JSON inside a single-quoted `openclaw gateway config.patch` command. 4. The operator follows the documented workflow and executes the printed command. 5. The injected shell command run ...[truncated 615 chars]- Remediation
View remediation
