subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def run_command(cmd: str) -> str: """Run a shell command and return output.""" try: result = subprocess.run(cmd, shell=True, capture_output=True, text=True, check=True) return result.stdout.strip() except subprocess.CalledProcessError as e: return f"ERROR: {e.stderr.strip()}"- Confidence
- 96% confidence
- Finding
- The helper executes shell commands with `shell=True`, which is unsafe because any string passed into `run_command` is interpreted by the shell. In this file, several command strings incorporate values such as plugin names and config paths, and even though current inputs are mostly hardcoded, the primitive itself is dangerous and can become command injection if those values are ever influenced by external data or unexpected environment behavior.
