// 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

PlainCVE Team · Published 2026-09-24 · AI-assisted · Press brief ↓

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 affectedWorkflows 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 happensIf 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 nowUpgrade 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)
  • Vendor / maintainerGoogle advisory: workflows that pin gemini_cli_version should upgrade to a patched version and audit their settingsyou are encouraged to upgrade to one of the patched versions and audit the workflow settings that use Gemini CLI.github.com
  • Vendor / maintainerThe Action's trust guidance: workflows handling untrusted content should use least privilege and prefer maintainer-triggered runsGrant only the minimum privileges necessary for the workflow to complete its task.github.com
  • ResearchersPillar also suggests gating AI workflow triggers on author_associationany issues:opened event without an author_association gate is a prompt injection surface.pillar.security
  • Our assessmentChecking outside PRs for changes to .gemini/ and rotating secrets the affected workflows could reach are PlainCVE's inferences; no official indicators or detection guidance were published
Affected versionsGemini CLI before 0.39.1, plus 0.40.0-preview.2; run-gemini-cli Action before 0.1.22
View evidence: sources disagree(4)
  • CVE recordDisputedCVE record: Gemini CLI before 0.39.1 and the Action before 0.1.22 are affected on headless CI; for the preview line it only says < 0.39.1Google Gemini CLI (versions prior to 0.39.1) and run-gemini-cli GitHub Action (versions prior to 0.1.22) on headless CI platformscveawg.mitre.org
  • Vulnerability databaseDisputedNVD's affected configuration also lists 0.40.0-preview.2, unlike the CVE record"criteria":"cpe:2.3:a:google:gemini-cli:0.40.0:preview2:*:*:*:node.js:*:*"services.nvd.nist.gov
  • Vendor / maintainerGoogle advisory: older versions automatically trusted the workspace in headless CI mode and loaded its configuration and environment variablesIn previous versions, Gemini CLI running in CI environments (headless mode) automatically trusted workspace folders for the purpose of loading configuration and environment variables.github.com
  • Our assessmentThe advisory says the change affects all Gemini CLI GitHub Actions; that actual exploitation still requires the workflow to process untrusted content is PlainCVE's interpretation, not Google's statement
Fixed versionsGemini CLI 0.39.1, 0.40.0-preview.3 or later; run-gemini-cli Action 0.1.22 or later
View evidence(3)
  • Vendor / maintainerGoogle advisory: the fixes are in Gemini CLI 0.39.1 and 0.40.0-preview.3The folder trust and tool allowlisting mitigations are available in @google/gemini-cli version 0.39.1 and 0.40.0-preview.3.github.com
  • Vendor / maintainerGoogle advisory: an Action that does not pin gemini_cli_version runs the latest CLI by defaultBy default, the run-gemini-cli GitHub Action will receive and run the latest version of gemini-cli.github.com
  • Vendor / maintainerFix PR #25814: untrusted workspaces no longer load .env, and headless runs stop on an untrusted folderIn headless mode, execution is now blocked if the current directory is untrusted.github.com
CVSS vector
Show full vectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Timeline
  • Introduced 2025-06-25 · First version 0.1.0 published (affected range starts at 0) source
  • First public 2026-04-24
CISA KEVNot listed(Not being in KEV does not mean it has not been exploited)
View evidence(2)
  • Our assessmentOur 2026-09-24 snapshot of the CISA KEV catalog does not list this CVE; not being listed does not mean it has not been exploited
  • Our assessmentWe found no source reporting exploitation of this flaw in the wild

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.

DETECTCheckAm I affected? Any signs of compromise?
  1. 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 check
    grep -rnE "run-gemini-cli|gemini_cli_version" .github/workflows/
  2. 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 check
    npm ls -g @google/gemini-cli
  3. 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 check
    git log --all --oneline -- .gemini/
MITIGATEFix / mitigatePatch; block it if you cannot patch yet
  1. 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.

  2. 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.

RESPONDRespondIf you find signs of compromise
  1. 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.

HARDENHardenPrevent the next one
  1. 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.

  2. 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
ComponentUpgrade to
@google/gemini-cli (npm)0.39.1; 0.40.0-preview.3 on the preview line
google-github-actions/run-gemini-cli0.1.22
  1. 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.
  2. 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 say GEMINI_CLI_TRUST_WORKSPACE. There is also a --skip-trust flag. We couldn’t confirm which name current versions accept.
  3. 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.
  4. After the fix, an untrusted folder blocks workspace settings.json, .env files, 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.

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: 1. The attacker opens a pull request containing a malicious .gemini/.env → 2. The CI workflow runs Gemini CLI in headless mode on the PR → 3. Older versions trust the workspace automatically in CI and load the project's .env → 4. The container launcher uses those values before the sandbox starts, running commands on the host → 5. The attacker reaches the secrets and source code available to the workflowCVE-2026-12537 · Gemini CLI headless CI workspace trust flaw: a .gemini/.env file in an outside PR can runcommands on the host before the sandbox startsAttackerYour systemThe 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. 1The attacker opensa pull requestcontaining amaliciou…The CI workflow runs Gemini CLI in headless mode on the PR — For example, the run-gemini-cli Action reviewing PRs automatically. 2The CI workflowruns Gemini CLI inheadless mode onthe PROlder 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/. 3Older versionstrust theworkspaceautomatically i…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. 4The containerlauncher usesthose valuesbefore the sandbo…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. 5The attackerreaches thesecrets and sourcecode available t…Attack pathCan be stopped herePlainCVE · plaincve.date/en/vulns/cve-2026-12537-gemini-cli-headless-workspace-trust · CC BY 4.0
Free to use in reporting and teaching under CC BY 4.0. Attribution is already on the image.
  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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

ConditionAffected?
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 codeDoes 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 laterFixed
Action with no gemini_cli_version setPer the advisory, it uses the latest patched CLI by default
Interactive Gemini CLI use on your own machineInteractive mode already asks before trusting a folder, so this remote scenario doesn’t apply
CI workflows that only handle the team’s own trusted codeThere’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 .env

The 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

DateEvent
2026-04-16 to 04-20Pillar reports the --yolo-related attack chain (the other issue); Google disables vulnerable workflows
2026-04-23Fix PR #25814 merged
2026-04-24Gemini CLI v0.39.1 and Action v0.1.22 released; GHSA published
2026-04-29 to 04-30Novee publishes its write-up; The Register and The Hacker News cover it (The Register says no CVE had been assigned yet)
2026-06-17CVE ID reserved
2026-06-24CVE published by GoogleCloud
2026-07-02NVD 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

Reviewed2026-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

  1. OtherFirst version 0.1.0 published (affected range starts at 0) · registry.npmjs.org · accessed 2026-09-24
  2. 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
  3. AdvisoryGemini CLI: Remote Code Execution via workspace trust and tool allowlisting bypasses · GitHub Advisory Database, 2026-04-24 · accessed 2026-09-23
  4. CVE / NVD / OSVCVE-2026-12537 record (CVE Services API) · CVE Program / GoogleCloud CNA, 2026-06-24 · accessed 2026-09-23
  5. CVE / NVD / OSVCVE-2026-12537 (NVD API) · NIST NVD, 2026-06-24 · accessed 2026-09-23
  6. 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
  7. Patch / releaseComparing v0.39.0...v0.39.1 · Google (google-gemini), 2026-04-24 · accessed 2026-09-23
  8. Patch / releaseRelease v0.39.1 · Google (google-gemini), 2026-04-24 · accessed 2026-09-23
  9. Patch / releaserun-gemini-cli Release v0.1.22 · Google (google-github-actions), 2026-04-24 · accessed 2026-09-23
  10. VendorTrusted Folders · Google (google-gemini) · accessed 2026-09-23
  11. VendorTrust Guidance · Google (google-github-actions) · accessed 2026-09-23
  12. VendorBest Practices · Google (google-github-actions) · accessed 2026-09-23
  13. ResearchGoogle Gemini CLI CVSS 10.0 RCE Vulnerability: Critical Security Advisory · Novee Security, 2026-04-29 · accessed 2026-09-23
  14. ResearchUpdate to Gemini CLI and run-gemini-cli Trust Model · Novee Security · accessed 2026-09-23
  15. ResearchMy Agentic Trust Issues: From Prompt Injection to Supply-Chain Compromise on gemini-cli · Pillar Security, 2026-05-05 · accessed 2026-09-23
  16. NewsGoogle fixes CVSS 10.0 vulnerability in Gemini CLI · The Register, 2026-04-30 · accessed 2026-09-23
  17. 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.

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}
}