subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
return 0 try: result = subprocess.run(cmd, check=False) if result.returncode != 0: print(f"[home_music] scene '{scene}' exited with code {result.returncode}") if raise_on_error:- Confidence
- 89% confidence
- Finding
- The code executes an external program using a path that can be overridden by the HOME_MUSIC_SCRIPT environment variable or resolved from PATH, with no validation that the target is the expected trusted script. While subprocess.run is invoked without shell=True, reducing shell-injection risk, this still enables arbitrary code execution if an attacker can influence the environment or PATH seen by the calling automation.
