subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
# Build the environment by sourcing the bash file env_command = f"source {ros_setup_path} && env" try: env_proc = subprocess.run(['bash', '-c', env_command], stdout=subprocess.PIPE, text=True, check=True) ros_env = {} for line in env_proc.stdout.splitlines(): if '=' in line:- Confidence
- 90% confidence
- Finding
- The wrapper builds a shell command using a value loaded from config.json and executes it via `bash -c`. If `ros_setup_path` is attacker-controlled or tampered with, shell metacharacters can inject arbitrary commands before `env` runs, leading to arbitrary code execution. In a security wrapper that claims strict read-only behavior, this undermines the trust boundary entirely.
