Summary
An OS command injection issue in the container launcher of the Google Gemini CLI and its run-gemini-cli GitHub Action allows untrusted environment configuration to influence shell commands.
On headless CI platforms, a maliciously crafted .gemini/.env file can enable an unprivileged attacker to execute code on the host before sandboxing or isolation is applied.
Affected context
This vulnerability arises in environments where the Google Gemini CLI and the run-gemini-cli GitHub Action are used to launch workloads, particularly on headless CI platforms.
It depends on the presence and parsing of .gemini/.env configuration files that can be modified or supplied by untrusted parties, and on container launch flows that build shell commands from these values before isolation or sandboxing is enforced.
Exploit preconditions
- Attack surface: CI/container launch workflows driven by Google Gemini CLI or the run-gemini-cli GitHub Action
- Required access: Ability to create, modify, or control the
.gemini/.envfile within the project or working directory used by the CI job - Trigger point: Execution of the container launcher or related automation that reads
.gemini/.envand constructs OS-level commands - Why exploitation is possible: Input from
.gemini/.envis insufficiently validated (CWE-20) and interpolated into shell commands in an unsafe manner (CWE-78), allowing attacker-controlled data to break out of intended arguments and inject additional commands
Why this happens
The root cause is the improper neutralization of special characters and control structures when user-controllable configuration values are incorporated into OS command lines.
Values from .gemini/.env are treated as trusted and embedded into command strings without robust validation, escaping, or use of safer invocation primitives.
This pattern corresponds to CWE-78 (OS Command Injection), with contributing factors from CWE-20 (Improper Input Validation), where data from configuration files is assumed benign and used directly to influence shell execution context.
Potential impact
- Execution of arbitrary commands on the CI host prior to sandbox or container isolation
- Compromise of CI runners, including theft or misuse of build secrets and tokens
- Tampering with build artifacts, test results, or deployment pipelines
- Lateral movement to other systems reachable from the compromised CI environment
- Introduction of malicious code into repositories or supply-chain paths
General mitigation guidance
Effective mitigation focuses on reducing trust in configuration inputs and eliminating direct shell interpolation of user-controlled data.
Common defensive patterns include:
- Avoiding shell-based command construction; instead, using APIs or subprocess invocation with argument arrays that do not require manual quoting
- Applying strict validation and whitelisting on values read from
.gemini/.env, constraining them to expected formats and ranges - Normalizing and sanitizing any configuration-derived strings before they influence OS command lines or environment variables
- Designing CI and container launch flows so that configuration files come from controlled, reviewed sources and are not writable by untrusted actors
- Running CI jobs and launchers with least-privilege accounts and isolating them from sensitive host resources, reducing the blast radius if misconfiguration occurs
How teams detect issues like this
Detection typically combines code-level analysis with CI configuration review.
Helpful approaches include:
- Static analysis rules that flag string concatenation or interpolation used to build shell commands from configuration or environment values
- Code review checklists that call out any use of shell interpreters,
system-like calls, or generic subprocess wrappers receiving raw strings - Repository policies that restrict or audit modifications to
.gemini/.envand similar configuration artifacts, especially in shared CI environments - Automated security tooling in CI that scans launcher scripts and workflows for command injection patterns and unvalidated configuration usage

