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
- 93% confidence
- Finding
- The code builds a shell command with an unquoted, dynamically configured path: `source {ros_setup_path} && env`, then executes it via `bash -c`. If `config.json` is modified and `ros_setup_path` contains shell metacharacters such as `;` or command substitution, arbitrary commands will run before the intended `env`. In a skill advertised as a strict sandboxed executor, this is especially dangerous because configuration is treated as trusted code execution input.
