subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run(cmd, timeout=300, check=True): """执行shell命令""" print(f"[CMD] {cmd}", file=sys.stderr) result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout) if result.returncode != 0 and check: print(f"[ERROR] stdout: {result.stdout}", file=sys.stderr) print(f"[ERROR] stderr: {result.stderr}", file=sys.stderr)- Confidence
- 98% confidence
- Finding
- The helper run() executes a fully interpolated shell command with shell=True. Multiple parts of those command strings are derived from untrusted or loosely trusted data such as story text prompts, output paths, and environment-configured values, so shell metacharacters can lead to command injection and arbitrary local code execution.
