T09 · Insecure Skill Coding Practices
- Location
omie_energy.py:286- Finding
Arbitrary Shell Command Execution Through Smart-Home Control Arguments
- Content
View full analysis
ON command", args.on_command, execute) action_taken = True if args.price_above is not None and price_kwh >= args.price_above: if args.off_command: run_cmd("Price is above threshold -> OFF command", args.off_command, execute) action_taken = True ``` ```python s4.add_argument("--on-command") s4.add_argument("--off-command") s4.add_argument("--execute", action="store_true") ``` ### Technical Analysis The `--on-command` and `--off-command` arguments accept unrestricted strings. When `--execute` is supplied and the corresponding price threshold matches, the selected string is passed directly to: ```python subprocess.run(cmd, shell=True, check=True) ``` Setting `shell=True` causes the operating-system shell to interpret command separators, pipelines, redirections, variable expansion, command substitution, and other shell syntax. Consequently, the interface does not restrict execution to the intended smart-home command. The behavior is documented and execution requires the explicit `--execute` option, so this is not a hidden backdoor. However, it remains an exploitable command-injection boundary whenever command arguments can be influenced by an untrusted user, generated content, copied instructions, or another automation layer. ### Attack Path 1. An attacker influences the value supplied to `--on-command` or `--off-command`, such as through malicious copied instructions or untrusted Agent-generated ...[truncated 1258 chars]- Remediation
View remediation
