How to Protect Your Systems from the Critical Gemini CLI Remote Code Execution Vulnerability
A step-by-step guide to identify, patch, and mitigate the CVSS 10 Gemini CLI RCE vulnerability affecting npm and GitHub Actions users.
Introduction
In a recent disclosure, Google confirmed a maximum-severity security flaw in the Gemini CLI – specifically in the @google/gemini-cli npm package and the associated google-github-actions/run-gemini-cli GitHub Actions workflow. This vulnerability, rated CVSS 10.0, allows an unauthenticated, unprivileged external attacker to force their own malicious configuration content to be loaded as Gemini configuration, leading to arbitrary command execution on the host system. If you use Gemini CLI in your development pipelines or local environment, your systems could be at immediate risk. This step-by-step guide will help you understand the vulnerability, audit your usage, and apply the necessary patches and mitigations to prevent exploitation.

What You Need
- Access to systems where Gemini CLI is installed (local machines, CI runners, GitHub Actions workflows).
- Knowledge of your version of
@google/gemini-cli(checkpackage.jsonor runnpm list @google/gemini-cli). - Access to your GitHub repositories if using the GitHub Actions workflow.
- Permission to update npm packages and modify GitHub Actions configurations.
- Basic familiarity with command-line tools and YAML editing.
- An understanding of security concepts like input validation and least privilege.
Step-by-Step Mitigation Guide
Step 1: Identify Affected Components
First, determine if your environment uses any of the vulnerable components. The vulnerability affects both:
- The npm package
@google/gemini-cli– any version prior to the patch. - The GitHub Action
google-github-actions/run-gemini-cli– any version prior to the patch.
To check the npm package, run:
npm list @google/gemini-cli
If the package is installed globally, use npm list -g @google/gemini-cli. For the GitHub Action, review your .github/workflows/*.yml files for lines containing google-github-actions/run-gemini-cli@<version>. If you are using an unpinned version (e.g., @main or @latest), you are especially vulnerable because the attacker could target the Action’s repository itself.
Step 2: Update to the Patched Version
Google has released patches for both components. Update immediately:
- For the npm package: Run
npm update @google/gemini-clior specify the latest version in yourpackage.jsonand reinstall. Verify the update withnpm list @google/gemini-cliand ensure it matches the patched version (check Google’s release notes). - For the GitHub Action: Update the version tag in your workflow file to the latest stable release, e.g.,
google-github-actions/run-gemini-cli@v1.2.3(substitute the actual patched version). Then commit and push the change.
Do not rely on @main or @latest – always pin to a specific semantic version tag.
Step 3: Audit Your GitHub Actions Workflows for Unsafe Configuration Loading
The vulnerability allowed attackers to inject malicious Gemini configuration. Even after patching, it is good practice to review how your workflows load configuration:

- Avoid using untrusted inputs (e.g., issue comments, pull request titles) directly as Gemini configuration sources.
- If you use environment variables or external files for configuration, ensure they are from trusted sources and properly validated.
- Inspect your workflow events that trigger Gemini runs – for instance, if you run Gemini on
issue_commentorpull_request_target, an external contributor could potentially craft a malicious comment that gets interpreted as configuration. Disable such triggers or add strict sanitization.
Step 4: Implement Input Validation and Least Privilege
Even after the patch, your overall security posture matters:
- Validate all inputs before they reach Gemini CLI. For example, if you read a configuration file from a user-supplied path, restrict it to a safe directory.
- Apply the principle of least privilege to your GitHub Actions tokens. Use
contents: readandissues: readinstead of broad write permissions. This limits what an attacker can do even if they manage to execute code. - Consider running Gemini in an isolated virtual environment or container with reduced capabilities.
Step 5: Monitor for Signs of Exploitation
Finally, check for any unusual activity that might indicate previous compromise:
- Review GitHub Actions logs for unexpected commands or configuration loading.
- Check your CI/CD pipeline for unexpected file changes or outbound connections.
- Look for any modified
.geminior configuration files that you did not author. - If you detect any anomaly, assume the system is compromised and take full remediation steps (rotate secrets, rebuild runners, etc.).
Tips for Ongoing Security
- Stay informed: Subscribe to Google’s security advisories and monitor npm/GitHub for new releases of Gemini CLI.
- Automate updates: Use Dependabot or Renovate to automatically open pull requests when new patched versions are available.
- Regular audits: Periodically review your GitHub Actions workflows and npm dependencies for security best practices.
- Limit attack surface: Only run Gemini CLI from trusted contexts – avoid exposing it to public input channels.
By following these steps, you can significantly reduce the risk posed by this critical vulnerability and protect your development infrastructure from remote code execution attacks.