subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
args = " ".join(f"{k}={v}" for k, v in kwargs.items()) cmd = f"mcporter call {tool} {args}" try: r = subprocess.run(cmd, shell=True, capture_output=True, text=True, env=ENV, timeout=60) if r.stdout.strip(): return json.loads(r.stdout) except (json.JSONDecodeError, subprocess.TimeoutExpired) as e:- Confidence
- 98% confidence
- Finding
- The script builds a shell command by concatenating the tool name and kwargs into a single string and executes it with shell=True. Because keyword values originate from user input and are not quoted or validated, an attacker can inject shell metacharacters and execute arbitrary commands on the host.
