subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def _send_to_server(line): result = subprocess.run( ["docker", "exec", SERVER_CONTAINER, "sh", "-c", f"echo {shlex.quote(line)} > {SERVER_FIFO}"], capture_output=True, text=True,- Confidence
- 96% confidence
- Finding
- This is a real command-injection risk because the code invokes `sh -c` inside the container and embeds attacker-influenced content (`line`) into a shell command. Although `shlex.quote(line)` helps, the redirection target (`SERVER_FIFO`) is still interpreted by the shell and the overall design routes user-controlled subscription strings through a shell unnecessarily, increasing the blast radius if constants or inputs change or are not strictly controlled elsewhere.
