T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/audio/play_http.py:14
- Finding
- Shell Command Injection Through an Untrusted Audio URL<![CDATA[ ## Vulnerability Details **File Location**: `scripts/audio/play_http.py:14-15` **Vulnerability Type**: OS command injection through `shell=True` **Risk Level**: High ### Vulnerable Code ```python cmd = f'mplayer "{args.url}"' subprocess.run(cmd, shell=True, check=True) ``` ### Technical Analysis The user-controlled `--url` argument is interpolated into a command string and executed through a system shell. Quoting the value does not make it safe because a malicious value can contain quote characters and shell metacharacters that terminate the intended argument and introduce additional commands. The program does not validate the URL scheme, destination, or characters before invoking the shell. Shell interpretation is unnecessary because `mplayer` can be executed directly with an argument array. ### Attack Path 1. An attacker causes the Skill or its controlling agent to invoke `play_http.py` with a crafted `--url`. 2. The crafted value is inserted into `cmd` without escaping. 3. `subprocess.run(..., shell=True)` passes the complete string to the shell. 4. The shell interprets attacker-controlled syntax as additional commands. 5. Those commands execute with the privileges of the Skill process. ### Impact Assessment Successful exploitation permits arbitrary command execution under the account running the Skill. The attacker could read or modify files available to that account, access attached robot hardware, invoke other installed programs, interfere with robot operation, or use accessible credentials such as environment-provided API keys. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not invoke a shell. Pass arguments as a list: ```python from urllib.parse import urlparse import subprocess parsed = urlparse(args.url) if parsed.scheme != "https": raise ValueError("Only HTTPS audio URLs are allowed") subprocess.run(["mplayer", args.url], check=True) ``` - Restrict accepted schemes to HTTPS. - If URLs are expected only from known services, enforce a hostname allowlist. - Consider blocking loopback, link-local, and private network destinations to reduce server-side request forgery and local-service access risks. - Apply timeouts and resource limits to the media player process. ]]>
