subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run_cmd(cmd): """执行命令,返回 (stdout, returncode)。仅用于只读操作。""" result = subprocess.run(cmd, shell=True, capture_output=True, text=True) return result.stdout.strip(), result.returncode # =============================================- Confidence
- 97% confidence
- Finding
- `run_cmd` executes arbitrary shell text with `shell=True`, which allows command injection if any untrusted input ever reaches this helper. Although it is documented as read-only, the implementation imposes no restriction on mutating commands, so this helper is a latent RCE primitive in a script that processes external migration packages.
