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: return {"error": f"API 调用超时: {product} {api}"} except FileNotFoundError:- Confidence
- 95% confidence
- Finding
- The code constructs a shell command string and executes it with shell=True using values derived from function arguments and environment variables. Although shlex.quote reduces direct metacharacter injection risk, invoking a shell is still unnecessarily dangerous in an agent context because untrusted inputs can influence CLI flags and the executed binary resolution, increasing the risk of command/parameter abuse.
