subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def _run_metric_command(self) -> str: """Execute the metric command and return output.""" try: proc = subprocess.run( shlex.split(self.config.metric_command), shell=False, cwd=self.config.work_dir,- Confidence
- 91% confidence
- Finding
- The code executes `self.config.metric_command` via `subprocess.run(...)` after only tokenizing it with `shlex.split`. While `shell=False` avoids classic shell metacharacter injection, it still permits execution of any attacker-controlled program/arguments if `metric_command` is untrusted, which can lead to arbitrary local command execution in the loop's working directory. In this skill's context, the loop is explicitly autonomous and repeatedly invokes the configured command, which increases risk because a dangerous command could be executed many times.
