subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
) def generate_image(prompt: str, out_path: str) -> str: result = subprocess.run( ["uv", "run", NANO_BANANA_SCRIPT, "--prompt", prompt, "--filename", out_path, "--resolution", "1K"], capture_output=True, text=True, env={**os.environ, "GEMINI_API_KEY": os.environ.get("GEMINI_API_KEY", "")}- Confidence
- 95% confidence
- Finding
- The script invokes an external program via subprocess to generate the image, and the executable script path is configurable through the NANO_BANANA_SCRIPT environment variable. Although shell injection is avoided by using an argument list, this still enables execution of arbitrary code if that environment variable or the referenced script is tampered with, which is especially dangerous because sensitive environment variables are also passed into the child process.
