// threat brief
Gemini CLI headless CI workspace trust flaw: a .gemini/.env file in an outside PR can run commands on the host before the sandbox starts
- CVSS
- 7.8 HIGH
- CISA KEV
- Not listed
- Weakness
- CWE-78 · CWE-20
- Topics
- Supply chain · AI security
Human review 2026-09-24Command tests: none yetReproduced: not yetVerification record ↓
In CI, Gemini CLI trusted any workspace automatically, so a malicious .gemini/.env in a pull request could run commands on the build host.
| Who is affected | Workflows that run Gemini CLI stable before 0.39.1 or preview before 0.40.0-preview.3 (so 0.40.0-preview.2 is affected) or the run-gemini-cli GitHub Action before 0.1.22 in headless CI mode on content outsiders can influence, such as pull requests from outside contributors. Normal interactive use is not in scope. |
|---|---|
| What happens | If those conditions hold, an attacker can run commands on the build machine and reach whatever secrets, credentials and source code that workflow can access. No source reports exploitation in the wild. |
| What to do now | Upgrade Gemini CLI to 0.39.1 (or 0.40.0-preview.3) and the Action to 0.1.22; workflows that pin gemini_cli_version must bump it by hand. Only turn on workspace trust for workflows that handle trusted content alone.View evidence(4)
|
| Affected versions | Gemini CLI before 0.39.1, plus 0.40.0-preview.2; run-gemini-cli Action before 0.1.22View evidence: sources disagree(4)
|
| Fixed versions | Gemini CLI 0.39.1, 0.40.0-preview.3 or later; run-gemini-cli Action 0.1.22 or laterView evidence(3)
|
| CVSS vector | Show full vectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| Timeline |
|
| CISA KEV | Not listed(Not being in KEV does not mean it has not been exploited)View evidence(2)
|
Blue team playbook
Check, fix / mitigate, respond, harden. Matching the affected versions does not mean you were compromised, and a check that finds nothing does not prove you are safe; each item says what it can and cannot show. Tagged steps point to where the attack flow below can be stopped.
- 01Find workflows using run-gemini-cli and any pinned versions
Act if the Action is below 0.1.22 or gemini_cli_version is pinned below 0.39.1. Per the advisory, workflows that don't set gemini_cli_version use the latest patched CLI by default.
Read-only checkgrep -rnE "run-gemini-cli|gemini_cli_version" .github/workflows/ - 02Check the Gemini CLI version installed locally or in images
Affected versions: stable releases below 0.39.1, and preview releases below 0.40.0-preview.3 (so 0.40.0-preview.2 is affected).
Read-only checknpm ls -g @google/gemini-cli - 03Check whether outside PRs touched .gemini/
No official indicators or detection guidance were published. PlainCVE suggests reviewing past CI runs on outside PRs and looking for PRs that added or changed the .gemini/ directory.
Read-only checkgit log --all --oneline -- .gemini/
- 01Upgrade Gemini CLI and the Action
Gemini CLI to 0.39.1 or 0.40.0-preview.3, the Action to 0.1.22; workflows that pin versions must bump them and review their settings.
- 02Enable workspace trust only for trusted workflows
After the fix, CI no longer trusts the workspace by default. Set the trust environment variable or --skip-trust only when the workflow handles trusted content alone; sources disagree on the variable name, so check the docs for your version.
- 01Rotate secrets the affected workflows could reach
If an affected workflow ran on untrusted PRs, rotate the tokens and credentials it could access. This is PlainCVE's inference, not official guidance, and does not mean a leak is confirmed.
- 01Don't run AI workflows automatically on outside fork content
The official trust guidance prefers workflows that maintainers trigger by hand; Pillar also suggests gating triggers on author_association.
- 02Least-privilege tokens and a minimal tool set
For example grant only issues: read and avoid broad ones like actions: write; allow a small set of read-only tools; set persist-credentials: false on checkouts that handle untrusted input.
Full remediation steps and notes
| Component | Upgrade to |
|---|---|
| @google/gemini-cli (npm) | 0.39.1; 0.40.0-preview.3 on the preview line |
| google-github-actions/run-gemini-cli | 0.1.22 |
- This is a breaking change. After upgrading, CI no longer trusts the workspace by default. Pipelines that relied on workspace settings won’t load them, and headless runs in an untrusted folder stop with
FatalUntrustedWorkspaceError. Decide which workflows handle only trusted content before you turn trust on. - Check your version’s docs for the trust variable name. The advisory and the fix PR say
GEMINI_TRUST_WORKSPACE. The current CLI docs and the Action’s trust guidance sayGEMINI_CLI_TRUST_WORKSPACE. There is also a--skip-trustflag. We couldn’t confirm which name current versions accept. - Don’t turn trust on for workflows that process outside PRs just to get them working again. That switches the fix off. Harden those workflows first, following the official trust guidance: least-privilege tokens, manual triggers and read-only tools only.
- After the fix, an untrusted folder blocks workspace
settings.json,.envfiles, extension management, tool auto-accept, automatic memory and context loading, MCP servers and custom commands (official docs).
Attack flow
Read left to right: this is the order the attack happens in. A blue shield means the step can be stopped; the earlier, the better. Click an icon for details.
- Attacker
The attacker opens a pull request containing a malicious .gemini/.env
No project membership is needed; the attacker only has to be able to open a PR or otherwise influence the workspace contents.
Defense: Don't run AI workflows automatically on outside fork content; have maintainers trigger them by hand, or gate on author_association.
- Your system
The CI workflow runs Gemini CLI in headless mode on the PR
For example, the run-gemini-cli Action reviewing PRs automatically.
Defense: Following the Action's trust guidance, treat issues and PRs from non-collaborators as untrusted.
- Your system
Older versions trust the workspace automatically in CI and load the project's .env
Interactive mode asks the user to trust a folder first, but headless mode skipped that and loaded settings such as environment variables from .gemini/.
Defense: Upgrade to Gemini CLI 0.39.1 / Action 0.1.22: untrusted folders no longer load .env, and headless runs stop with an error.
- Your system
The container launcher uses those values before the sandbox starts, running commands on the host
Because this happens outside the sandbox, the sandbox offers no protection. Which variable is involved, and how, has not been published.
Defense: As above; upgrading is the real fix.
- Attacker
The attacker reaches the secrets and source code available to the workflow
Researchers at Novee say this can lead to token theft and supply-chain pivots.
Defense: Give workflows least-privilege tokens, set persist-credentials: false on checkouts that handle untrusted input, and keep secrets in GitHub Secrets.
Who is affected
| Condition | Affected? |
|---|---|
Gemini CLI stable before 0.39.1, or preview before 0.40.0-preview.3 (0.40.0-preview.2 is affected), running in headless CI mode and on a workspace whose config files an attacker can control (for example a .gemini/.env brought in by an outside PR) | Affected |
| run-gemini-cli Action before 0.1.22, and the affected CLI it runs works on a workspace where an attacker can place config files (for example a checkout of outside PR code) | Affected |
| Workflow only reads issue or comment text, and the workspace is your own trusted code | Does not meet this CVE’s condition (it needs an untrusted .gemini/.env); the separate --yolo tool-allowlist issue in the same advisory may still apply, see below |
| Gemini CLI 0.39.1, 0.40.0-preview.3 or later; Action 0.1.22 or later | Fixed |
Action with no gemini_cli_version set | Per the advisory, it uses the latest patched CLI by default |
| Interactive Gemini CLI use on your own machine | Interactive mode already asks before trusting a folder, so this remote scenario doesn’t apply |
| CI workflows that only handle the team’s own trusted code | There’s no way for an attacker to get a file in, but upgrading is still recommended |
Sources describe the preview line differently. The CVE record says only ”< 0.39.1”, NVD also lists 0.40.0-preview.2, and the GitHub repository advisory says ”< 0.40.0-preview.3”.
Google’s advisory says the change “affects all” Gemini CLI GitHub Actions. PlainCVE reads this as referring to a behaviour change every user will notice. Actual exploitation still requires the workflow to process untrusted content. That is our interpretation, not a statement from Google.
How it works
Gemini CLI is Google’s AI coding assistant. It reads and writes code from the terminal, and through the run-gemini-cli Action it can run inside GitHub CI, the system that builds and tests code automatically whenever it changes. A common use is reviewing PRs automatically.
A project can ship its own settings in a .gemini/ folder, including a .env file. A .env file holds environment variables, the settings a program reads when it starts. Because those settings come from the code itself, Gemini CLI has “folder trust”: in interactive use it asks whether you trust the folder, and if you don’t, it ignores those settings.
The problem was that headless mode (CI, where nobody is there to click confirm) treated the workspace as trusted automatically. So a .gemini/.env in an outside contributor’s PR got loaded. According to the CVE record, those values reached the “container launcher”, the part that starts the sandbox. The launcher runs on the host before the sandbox starts, so the sandbox couldn’t protect anything. The result is that an attacker could run commands on the build machine. Novee says this exposes the secrets, credentials and source code the workflow can reach, which opens the door to token theft and supply-chain attacks.
Put simply, trust was decided by run mode, not by where the content came from. Google has not said which variable is involved or how the launcher used it, and this page doesn’t guess.
The flawed approach (conceptual illustration, not the original source code):
Show code example(python)
if headless_mode:
trusted = True # CI: just assume the folder is trusted
if trusted:
load_env(workspace / ".gemini/.env")
launch_container() # runs on the host before the sandbox, already influenced by .envThe fixed approach:
Show code example(python)
trusted = is_explicitly_trusted(workspace) # only if the user explicitly configured trust
if not trusted:
if headless_mode:
raise FatalUntrustedWorkspaceError # stop the run
# skip .env, workspace settings, MCP servers, etc.
else:
load_env(workspace / ".gemini/.env")
launch_container()A second issue in the same advisory (not part of this CVE): Google’s advisory GHSA-wpqr-6v78-jr5g also describes --yolo (auto-approve) mode ignoring the tool allowlist in ~/.gemini/settings.json, which could let prompt injection lead to remote code execution. Pillar Security reported most of that work. The CVE description covers only the .env / container launcher problem, and so does this page. Some secondary sources, including Novee’s vulnerability page and the GitHub Advisory Database summary, describe the two together, so keep that in mind when reading them.
Timeline
| Date | Event |
|---|---|
| 2026-04-16 to 04-20 | Pillar reports the --yolo-related attack chain (the other issue); Google disables vulnerable workflows |
| 2026-04-23 | Fix PR #25814 merged |
| 2026-04-24 | Gemini CLI v0.39.1 and Action v0.1.22 released; GHSA published |
| 2026-04-29 to 04-30 | Novee publishes its write-up; The Register and The Hacker News cover it (The Register says no CVE had been assigned yet) |
| 2026-06-17 | CVE ID reserved |
| 2026-06-24 | CVE published by GoogleCloud |
| 2026-07-02 | NVD analysis last modified |
The date of Novee’s report is unknown.
Further reading
- Scoring differences: NVD’s CVSS 3.1 score is 7.8 (local attack, user interaction required). Google’s (CNA) CVSS 4.0 score is 10.0, and the GHSA’s CVSS 3.1 score is also 10.0 (network-reachable, no interaction). The gap comes from judging the “outside PR triggers CI” scenario differently. This page’s severity field uses the NVD score.
- CWE mismatch: the CNA tags CWE-20 (improper input validation) and NVD tags CWE-78 (OS command injection). The CVE description’s own wording is closer to CWE-78. The GHSA lists CWE-20, 77, 78 and 200, covering both issues.
- CVE mapping: the GHSA page still shows “No known CVE”, yet the CVE record’s only reference is that GHSA.
- Credits: the GHSA credits Elad Meged (Novee Security) and Dan Lisichkin (Pillar Security). The CVE record credits Elad Meged and Devansh Batham. Devansh Batham’s link to this CVE could not be confirmed.
- Exploitation: no source reports exploitation in the wild. The record we were given says this CVE is not in CISA KEV, but CISA’s site could not be reached during research to confirm this independently.
- No official indicators of compromise were published. The detection and secret-rotation suggestions on this page are PlainCVE’s own inferences.
Verification Reviewed and checked against sources; not yet reproduced in our lab
| Reviewed | 2026-09-24 |
|---|
Verification records describe the environment and the result only, never reproduction steps or code that could attack other people’s systems. See our policy.
Sources
- OtherFirst version 0.1.0 published (affected range starts at 0) · registry.npmjs.org · accessed 2026-09-24
- AdvisoryGHSA-wpqr-6v78-jr5g — Update to Gemini CLI and run-gemini-cli Trust Model · Google (google-github-actions), 2026-04-24 · accessed 2026-09-23
- AdvisoryGemini CLI: Remote Code Execution via workspace trust and tool allowlisting bypasses · GitHub Advisory Database, 2026-04-24 · accessed 2026-09-23
- CVE / NVD / OSVCVE-2026-12537 record (CVE Services API) · CVE Program / GoogleCloud CNA, 2026-06-24 · accessed 2026-09-23
- CVE / NVD / OSVCVE-2026-12537 (NVD API) · NIST NVD, 2026-06-24 · accessed 2026-09-23
- Patch / releasefeat(cli): secure .env loading and enforce workspace trust in headless mode (PR #25814) · Google (google-gemini), 2026-04-23 · accessed 2026-09-23
- Patch / releaseComparing v0.39.0...v0.39.1 · Google (google-gemini), 2026-04-24 · accessed 2026-09-23
- Patch / releaseRelease v0.39.1 · Google (google-gemini), 2026-04-24 · accessed 2026-09-23
- Patch / releaserun-gemini-cli Release v0.1.22 · Google (google-github-actions), 2026-04-24 · accessed 2026-09-23
- VendorTrusted Folders · Google (google-gemini) · accessed 2026-09-23
- VendorTrust Guidance · Google (google-github-actions) · accessed 2026-09-23
- VendorBest Practices · Google (google-github-actions) · accessed 2026-09-23
- ResearchGoogle Gemini CLI CVSS 10.0 RCE Vulnerability: Critical Security Advisory · Novee Security, 2026-04-29 · accessed 2026-09-23
- ResearchUpdate to Gemini CLI and run-gemini-cli Trust Model · Novee Security · accessed 2026-09-23
- ResearchMy Agentic Trust Issues: From Prompt Injection to Supply-Chain Compromise on gemini-cli · Pillar Security, 2026-05-05 · accessed 2026-09-23
- NewsGoogle fixes CVSS 10.0 vulnerability in Gemini CLI · The Register, 2026-04-30 · accessed 2026-09-23
- NewsGoogle Fixes CVSS 10 Gemini CLI CI RCE and Cursor Flaws Enable Code Execution · The Hacker News, 2026-04-30 · accessed 2026-09-23
Press brief
In one sentence
Google's AI coding assistant Gemini CLI and its GitHub Action automatically trusted the code folder they were working on when run in CI (automated builds). That meant a pull request from an outsider could carry a settings file that runs commands on the build machine before the sandbox starts. Google released fixes in Gemini CLI 0.39.1 and Action 0.1.22 on April 24, 2026. No source reports exploitation, and the flaw is not in CISA's Known Exploited Vulnerabilities catalog.
Key facts
- Severity (NVD)
- CVSS 3.1 7.8 services.nvd.nist.gov
- Severity (Google, CNA)
- CVSS 4.0 10.0 cveawg.mitre.org
- Fixed versions
- Gemini CLI 0.39.1 / 0.40.0-preview.3; Action 0.1.22 github.com
- Advisory published
- 2026-04-24 (GHSA-wpqr-6v78-jr5g) github.com
- CVE published
- 2026-06-24 cveawg.mitre.org
Confirmed
- Older versions automatically trusted the workspace in headless CI mode and loaded settings from .gemini/ (Google advisory).
- A malicious .gemini/.env could reach the container launcher and run code on the host before the sandbox starts (CVE record).
- After the fix, .env loads only in trusted workspaces, and headless runs stop on untrusted folders (fix PR #25814).
Unconfirmed / disputed
- Scores differ widely: NVD rates it local with user interaction (7.8), Google rates it network-reachable with no interaction (10.0).
- Trust variable name: the advisory says GEMINI_TRUST_WORKSPACE, current docs say GEMINI_CLI_TRUST_WORKSPACE; which one current versions accept is unconfirmed.
- Credits disagree: the GHSA lists Elad Meged and Dan Lisichkin; the CVE record lists Elad Meged and Devansh Batham.
- Which environment variable is involved, and how the launcher used it, has not been published.
Quotable line
The AI agent was asked to review a stranger's code, and it took its instructions from that same code first.
Images
Download the share image (PNG) · Attack flow diagram (downloadable)
Please credit "PlainCVE" and link to this page. Full citation format is under "How to cite" below. Found a factual error? Report it.
Gemini CLI headless CI workspace trust flaw: a .gemini/.env file in an outside PR can run commands on the host before the sandbox starts Google's AI coding assistant Gemini CLI and its GitHub Action automatically trusted the code folder they were working on when run in CI (automated builds). That meant a pull request from an outsider could carry a settings file that runs commands on the build machine before the sandbox starts. Google released fixes in Gemini CLI 0.39.1 and Action 0.1.22 on April 24, 2026. No source reports exploitation, and the flaw is not in CISA's Known Exploited Vulnerabilities catalog. Key facts: - Severity (NVD):CVSS 3.1 7.8(https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2026-12537) - Severity (Google, CNA):CVSS 4.0 10.0(https://cveawg.mitre.org/api/cve/CVE-2026-12537) - Fixed versions:Gemini CLI 0.39.1 / 0.40.0-preview.3; Action 0.1.22(https://github.com/google-github-actions/run-gemini-cli/security/advisories/GHSA-wpqr-6v78-jr5g) - Advisory published:2026-04-24 (GHSA-wpqr-6v78-jr5g)(https://github.com/google-github-actions/run-gemini-cli/security/advisories/GHSA-wpqr-6v78-jr5g) - CVE published:2026-06-24(https://cveawg.mitre.org/api/cve/CVE-2026-12537) Confirmed: - Older versions automatically trusted the workspace in headless CI mode and loaded settings from .gemini/ (Google advisory). - A malicious .gemini/.env could reach the container launcher and run code on the host before the sandbox starts (CVE record). - After the fix, .env loads only in trusted workspaces, and headless runs stop on untrusted folders (fix PR #25814). Unconfirmed / disputed: - Scores differ widely: NVD rates it local with user interaction (7.8), Google rates it network-reachable with no interaction (10.0). - Trust variable name: the advisory says GEMINI_TRUST_WORKSPACE, current docs say GEMINI_CLI_TRUST_WORKSPACE; which one current versions accept is unconfirmed. - Credits disagree: the GHSA lists Elad Meged and Dan Lisichkin; the CVE record lists Elad Meged and Devansh Batham. - Which environment variable is involved, and how the launcher used it, has not been published. 「The AI agent was asked to review a stranger's code, and it took its instructions from that same code first.」— PlainCVE https://plaincve.date/en/vulns/cve-2026-12537-gemini-cli-headless-workspace-trust
How to cite this page
This article is CC BY 4.0. Please keep the attribution and link when republishing.
PlainCVE Team (2026). "Gemini CLI headless CI workspace trust flaw: a .gemini/.env file in an outside PR can run commands on the host before the sandbox starts". PlainCVE. https://plaincve.date/en/vulns/cve-2026-12537-gemini-cli-headless-workspace-trust (accessed YYYY-MM-DD)BibTeX
@misc{cve202612537geminicliheadlessworkspacetrust2026,
title = {Gemini CLI headless CI workspace trust flaw: a .gemini/.env file in an outside PR can run commands on the host before the sandbox starts},
author = {PlainCVE Team},
year = {2026},
howpublished = {PlainCVE},
url = {https://plaincve.date/en/vulns/cve-2026-12537-gemini-cli-headless-workspace-trust},
note = {Updated 2026-09-24}
}