subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
shell_cmd = " ".join(shlex.quote(c) for c in cmd) try: result = subprocess.run( shell_cmd, shell=True, capture_output=True, text=True, timeout=timeout, ) except subprocess.TimeoutExpired:- Confidence
- 96% confidence
- Finding
- The code constructs a shell command string and executes it with shell=True, even though some arguments can come from function parameters (product, api, params, region, profile). While shlex.quote reduces risk, invoking a shell is unnecessary and expands the attack surface; if any quoting edge case or future code change introduces untrusted input, this becomes command injection. In a diagnostic skill that interfaces with cloud APIs, abuse could execute arbitrary local commands under the agent's privileges.
