T09 · Insecure Skill Coding Practices
- Location
core/dispatcher.py:375- Finding
OS Command Injection Through Unvalidated Action Parameters
- Content
View full analysis
ActionResult: service = params.get("service", "") if server.os_type == "windows": cmd = f"Restart-Service -Name '{service}' -Force" else: cmd = f"systemctl restart {service}" result = executor.execute(cmd) return ActionResult( success=result.exit_code == 0, action="restart_service", server_id=server.id, output=result.stdout, ) ``` The same unsafe command-construction pattern is used for backup destinations, restore sources, database names, firewall ports, source CIDRs, and the WinRM port: ```python cmd = f"bash '{remote_script}' {db_name} {dest}" cmd = f"bash '{remote_script}' {db_name} {source}" cmd = f"bash '{remote_script}' '{ports_csv}' '{source_cidr}'" cmd = f"powershell -ExecutionPolicy Bypass -File '{remote_script}' -Port {port}" ``` ### Technical Analysis Values from the action `params` dictionary are directly interpolated into shell or PowerShell command strings. No strict type validation, allowlist, or context-appropriate escaping is applied before the resulting command is passed to an executor. Confirmation does not neutralize this vulnerability. It only determines whether an action may proceed; it does not ensure that individual parameters are safe. If an attacker can influence an action request or convince a user to confirm a misleading plan, shell metacharacters in a parameter are interpreted by the target command shell. For example, on Linux, a service parameter such as: ```text mysql; id; uname -a ``` produces: ```bash systemctl restart mysql; id; uname -a ``` Windows parameters enclosed in single quotes are ...[truncated 1300 chars]- Remediation
View remediation
