subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run_command(cmd: str, check: bool = True) -> str: """运行命令并返回输出""" print(f"Running: {cmd}") result = subprocess.run(cmd, shell=True, capture_output=True, text=True) if check and result.returncode != 0: print(f"Error: {result.stderr}") print(f"Exit code: {result.returncode}")- Confidence
- 98% confidence
- Finding
- The script builds a shell command as a single string and executes it with shell=True, which allows shell metacharacters in bot-supplied values such as agent_id or workspace_path to alter the command. Because those values come from a JSON config file and are not validated or escaped, an attacker who can influence that file could trigger arbitrary command execution under the user's account.
