subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run_step(name, cmd, timeout=30): print(f" ▶ [{name}] 执行中...", end=" ", flush=True) try: r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout) status = "✅" if r.returncode == 0 else "⚠️" output = r.stdout[:200] + (r.stderr[:100] if r.stderr else "") print(f"{status} (code={r.returncode})")- Confidence
- 95% confidence
- Finding
- The code executes shell commands via subprocess.run with shell=True, which is dangerous because it invokes a shell parser and expands metacharacters, environment variables, and shell startup behavior. In this pipeline context, command strings are sourced from workspace-controlled skill paths, so a compromised workspace, malicious symlink/path manipulation, or future dynamic command construction could lead to arbitrary command execution under the agent's privileges.
