subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run_cmd(cmd, cwd=None): """执行 shell 命令""" result = subprocess.run( cmd, shell=True, capture_output=True, text=True, cwd=cwd ) if result.returncode != 0:- Confidence
- 98% confidence
- Finding
- `run_cmd` executes an arbitrary string with `shell=True`, which enables shell metacharacter interpretation and command injection if any part of `cmd` is influenced by user input or upstream file/content-derived values. In a document-processing skill that handles untrusted contract files and paths, this creates a realistic path to unintended command execution on the host.
