T09 · Insecure Skill Coding Practices
Error
- Location
- SKILL.md:44
- Finding
- Untrusted Room Name Interpolated into Shell Command Templates## Vulnerability Details **File Location**: `SKILL.md`, lines 44-51 and 60-63 **Vulnerability Type**: Command injection through unsafe command construction guidance **Risk Level**: High The skill instructs the Agent to substitute a user-provided room name directly into shell command templates: ```markdown | User Says | Command | |-----------|---------| | Turn on the <room-name> AC / open AC | `scripts/midea_ac.py <room-name> on` | | Turn off the <room-name> AC / close <room-name> AC | `scripts/midea_ac.py <room-name> off` | | Toggle the <room-name> AC | `scripts/midea_ac.py <room-name> toggle` | | Warmer / more warm | Check status first, then increase temperature by 2 - 10 degrees | | Cooler / less heat | Check status first, then decrease temperature by 2 - 10 degrees | | Full speed / maximum | if mode is heat: `scripts/midea_ac.py <room-name> --temperature 30 --fan_speed max`, if mode is cool: `scripts/midea_ac.py <room-name> --temperature 16 --fan_speed max` | | Minimum speed | `scripts/midea_ac.py <room-name> --fan_speed low` | | <room-name> AC status / what's the <room-name> status | `scripts/midea_ac.py <room-name> status` | ## Before Executing 1. Navigate to skill directory: `cd ~/.openclaw/skills/midea_ac` 3. Run with uv: `python scripts/midea_ac.py <room-name> <command>` 3. Report the result to the user after execution ``` ### Technical Analysis The `<room-name>` placeholder originates from natural-language user input. The instructions do not require validation against the configured device names, shell-safe quoting, or execution through a process API that accepts an argument array. If an Agent follows these instructions by constructing a command string and passing it to a shell, shell metacharacters in the room name may be interpreted as command syntax rather than as one inert argument. Although the Python script itself does not invoke a shell, the vulnerable boundary is the skill's Agent-facing execu ...[truncated 1195 chars]
- Remediation
- ## Remediation Suggestions 1. Validate room names against an exact allowlist derived from `AC_IPS`; currently, only `livingroom` and `bedroom` should be accepted. 2. Reject unknown names before starting any process instead of inserting them into a command. 3. Execute the script with an argument array, such as `["python", "scripts/midea_ac.py", validated_room, validated_command]`, with shell processing disabled. 4. Update `SKILL.md` to explicitly prohibit concatenating natural-language input into shell command strings. 5. Validate commands and option values against explicit allowlists before execution. 6. Add a guard in `scripts/midea_ac.py` that reports an unknown device and exits before calling `Discover.discover_single`. 7. Add tests containing spaces, quotes, command separators, substitutions, and redirection characters to confirm that malformed room names are rejected and never interpreted by a shell.
