subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run_cmd(cmd): """执行命令""" try: result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=60) return result.stdout.strip(), result.stderr.strip(), result.returncode except Exception as e: return "", str(e), 1- Confidence
- 96% confidence
- Finding
- The helper executes arbitrary shell strings with `subprocess.run(..., shell=True)`, which is inherently dangerous because later call sites build commands via string interpolation. In this script, the `lines` argument is derived from `sys.argv` and inserted into shell commands without validation, enabling command injection if an attacker supplies crafted input.
