Gemini CLI Security: Sandbox, Trusted Folders, YOLO Mode and Antigravity CLI Security After the June 2026 Migration
A CVSS 10.0 flaw let an attacker run commands on a CI host before the Gemini CLI sandbox even started. Then Google cut off every consumer tier and moved everyone to a different CLI.
Direct answer
Gemini CLI security comes down to four things, and most write-ups only cover the first. One: CVE-2026-12537, scored 10.0 on CVSS v4, allowed pre-sandbox host code execution on headless CI runners through a crafted .gemini/.env file, and it is fixed in Gemini CLI 0.39.1 and run-gemini-cli 0.1.22. Two: the controls Google ships, which are trusted folders, a Docker or Podman sandbox, approval modes including YOLO, and admin-enforced tool allowlists, are real but Google itself states they "should not be considered a foolproof security boundary." Three: since June 18, 2026, Gemini CLI no longer serves Google AI Pro, AI Ultra or the free individual tier, so the population still running it is almost entirely organizations on Gemini Code Assist Standard or Enterprise licenses and paid API keys. Everyone else moved to Antigravity CLI, which inherited the same class of problem: Pillar Security demonstrated a prompt injection that reached arbitrary code execution through Antigravity's file search tool and bypassed Secure Mode entirely, because native tool calls run before Secure Mode evaluates them. Four: none of the above governs what the agent does after it has been hijacked. This page separates the patch work from the configuration work from the enforcement work, cites NVD, Google's own advisories and docs, and includes a table where the first rows say plainly that we are not the fix.
Try it live
Watch Agentshield block an attack in real time.
Pick a scenario and drive the inspection lane yourself. No signup needed.
Run a request
Inspection lane
INSPECTINGPolicy trace
High-risk action held for approval
Audit trail
- § · → → →
The risk
Gemini CLI arrived the way developer tools do now: one engineer installed it, it was free on a Google AI Pro account, and within a quarter it was in three repositories and a GitHub Action nobody reviewed. Then two things happened in the same eight weeks. Google published a maximum-severity advisory covering the exact CI configuration most teams had copied from a blog post, and Google announced that the free and Pro tiers would stop being served, forcing a migration to a different CLI with a different security model. Security teams that had never inventoried Gemini CLI now had to answer which version ran in which pipeline, which folders had been trusted, whether any job used the yolo approval mode against untrusted input, and whether the replacement tool was better or merely newer.
How Agentshield handles it
Treat it as three separate workstreams with three different owners, because the deadlines differ. Patching is the fast one and the floor is exact: Gemini CLI 0.39.1 or later, and google-github-actions/run-gemini-cli 0.1.22 or later. Anything below that in a CI workflow is remotely exploitable by whoever can open a pull request. Configuration is the standing one: enforce sandboxing and an explicit tool allowlist from a system-level settings file that workspace settings cannot override, keep folder trust on, and never combine the yolo approval mode with content an outsider can author. Migration is the third: Antigravity CLI is not a rename, it is a different harness with its own history of sandbox and persistence findings, so it needs its own review rather than an inherited sign-off. What none of the three reaches is the enforcement question. Every published attack on these tools ends the same way, with a hijacked agent calling a legitimate tool for an illegitimate reason. The control that survives that is not a better prompt filter, it is a scoped identity per agent, a default-deny policy on the actions themselves, a human gate on anything irreversible, and a record of every allowed and denied call kept somewhere the compromised host cannot rewrite.
The controls
The controls that secure the Gemini CLI and Antigravity CLI agents your developers run in terminals and CI jobs, and the tools those agents reach once a prompt has already gone wrong.
CVE-2026-12537: the CVSS 10.0 Gemini CLI vulnerability in CI
This is the one that matters most, because it needed no user interaction and it landed in the configuration teams were most likely to be running.
NVD describes it precisely: "Improper Neutralization used in an OS Command in the container launcher in Google Gemini CLI (versions prior to 0.39.1) and run-gemini-cli GitHub Action (versions prior to 0.1.22) on headless CI platforms allows an unprivileged attacker to achieve pre-sandbox host-level code execution a maliciously crafted .gemini/.env file." The phrase to read twice is pre-sandbox. The sandbox is the control most teams point to when asked whether the agent is contained. Here the code ran on the host before that container existed.
| Field | Value |
|---|---|
| Identifier | CVE-2026-12537, advisory GHSA-wpqr-6v78-jr5g |
| Score | CVSS v4.0 base 10.0 critical. NVD also lists a CVSS v3.1 base of 7.8, which assumes local access and user interaction. Use the v4 score for CI runners, where the attacker is remote and no human is involved |
| Weakness | CWE-78 OS command injection, with CWE-20 improper input validation |
| Affected | Gemini CLI before 0.39.1 and before 0.40.0-preview.3; google-github-actions/run-gemini-cli before 0.1.22 |
| Fixed | Gemini CLI 0.39.1 and 0.40.0-preview.3; run-gemini-cli 0.1.22. Advisory published April 24, 2026, NVD record published June 24, 2026 |
Google's advisory names two distinct defects. The first is folder trust in headless mode: "In previous versions, Gemini CLI running in CI environments (headless mode) automatically trusted workspace folders for the purpose of loading configuration and environment variables." A repository is a workspace folder. A pull request can add files to it. The fix, in Google's words, "aligns headless mode behavior with interactive mode, requiring folders to be explicitly trusted before configuration files (such as .env) are processed."
The second defect is quieter and, if you run agents in automation, more instructive. Tool allowlisting was ignored under the yolo approval mode. Teams had reasoned that yolo was acceptable in CI precisely because they had allowlisted a handful of safe commands. That allowlist was not being enforced. From 0.39.1 the policy engine evaluates allowlists under yolo as well, which is the behavior everyone assumed they already had.
That gap between assumed and actual enforcement is the recurring theme across every agent platform we cover, from Cursor to n8n to LiteLLM. The control existed, it was documented, and it was not on the path the request actually took.
How the GitHub issue to supply chain attack chain worked
The advisory is dry. The research behind it is not, and it is the clearest published illustration of why permission scope beats prompt hardening.
Pillar Security reported the issue to Google's open source vulnerability rewards program on April 16, 2026, submitted a full supply chain proof of concept against the gemini-cli repository itself on April 20, and Google published the advisory on April 24. The chain ran like this. An attacker opens a public GitHub issue containing hidden instructions. A Gemini-powered triage workflow reads the issue, because reading issues is its job. The injected instructions take control of the agent and have it read Git credentials out of .git/config and exfiltrate them. Those credentials carry actions:write, which is enough to trigger a second workflow against an attacker-controlled branch, and that second workflow yields a token with contents:write. At that point an outsider can push to the main branch of a repository with over 100,000 stars.
Nothing in that chain is a memory corruption bug or an exotic exploit. Every step is a tool the agent was legitimately allowed to use, invoked for a reason its operators never intended. The researchers' own summary of why the injection worked is the sentence worth taking into your next design review: "The model refused five researchers who asked for secrets by name. It ran our payload because we never mentioned secrets at all."
Read that as a boundary statement about detection. The model was trained to refuse the obvious phrasing, and it did. The payload simply did not use the obvious phrasing. Any control whose job is to recognize bad intent in text is playing a game where the attacker picks the words. Controls that constrain what the agent may do next are playing a game where you pick the rules. That is the argument for tool permissions over filtering, and we make the same case in prompt injection vs jailbreak.
Worth separating from this, because coverage regularly conflates them: GeminiJack, disclosed by Noma Labs, was a zero-click indirect prompt injection in Gemini Enterprise and Vertex AI Search, not the CLI. A poisoned document in Workspace caused Gemini Enterprise to retrieve it during a normal search and exfiltrate Gmail, Calendar and Docs content through a disguised image request. Same attack class, different product, different fix. If someone tells you GeminiJack means your CLI pipeline is exposed, they have not read either advisory.
Gemini CLI sandbox, trusted folders and YOLO mode: what each control actually stops
Google ships a genuinely reasonable set of controls. They are also narrower than their names suggest, and Google says so in its own enterprise documentation, which is more than most vendors in this category do.
| Control | What it does | What it does not do |
|---|---|---|
Trusted folders, setting security.folderTrust.enabled | Until you approve a folder, the CLI will not load that project's .gemini/settings.json, will not load its .env files, blocks installing, updating or uninstalling extensions, disables tool auto-acceptance so you are prompted before every tool run, and disables automatic memory loading from local settings | It is a decision gate, not a boundary. Once you trust a folder, everything above unlocks for it. Trusting a parent folder trusts every subdirectory under it, which is how a monorepo becomes one trust decision |
| Sandbox, Docker or Podman container, macOS Seatbelt profiles | Isolates tool execution away from your host filesystem and network. Enabled by default when you pass --yolo or --approval-mode=yolo | It did not stop CVE-2026-12537, because that executed in the container launcher before the sandbox existed. A sandbox contains what runs inside it and nothing about how it is started |
| Approval modes: default, plan, autoEdit, yolo | Default prompts per tool call. Plan reasons without acting. YOLO auto-approves every tool call. Privileged modes require a trusted folder; an untrusted directory permits only default and plan | YOLO plus untrusted input is the combination behind most published incidents. Before 0.39.1 it also silently ignored your allowlist |
Tool restriction: coreTools allowlist, excludeTools blocklist | Restricts which tools and shell commands the agent may call at all. Google is explicit about which to use: "The most secure approach is to explicitly add the tools and commands that users are permitted to execute to an allowlist" | Google is equally explicit about the alternative: "Blocklisting with excludeTools is less secure than allowlisting with coreTools, as it relies on blocking known-bad commands." A blocklist is a list of the attacks you thought of |
| Admin settings precedence | Four layers apply in order: system defaults, user settings, workspace settings, then system overrides. Per Google, "This means the System Overrides file has the final say," so a developer cannot loosen policy from inside a repository | Google's own caveat: "However, they should not be considered a foolproof security boundary. A determined user with sufficient privileges on their local machine may still be able to circumvent these configurations." These prevent accidental misuse and enforce corporate policy. They are not an adversary control on a machine the user owns |
That last row deserves credit rather than criticism. Google wrote down the limit of its own control instead of leaving buyers to discover it, which is the standard we hold ourselves to further down this page. The practical reading for a US security team: these settings are excellent for stopping a well-meaning engineer from doing something expensive, and they are not the thing standing between a hijacked agent and your production systems.
One genuine strength is worth stating plainly. Gemini CLI runs locally while the model runs in Google's cloud, and under Gemini Code Assist Standard and Enterprise licensing, Google states that customer code, inputs and generated recommendations are not used to train shared models. If your blocker is training data rather than runtime behavior, that is a real answer and it is on paper.
Antigravity CLI security after the June 18, 2026 migration
On May 19, 2026 Google announced that Gemini CLI was being transitioned to Antigravity CLI, and on June 18, 2026 the cutoff took effect. This is the single most important fact for scoping the work, and it is missing from most security guidance still circulating.
| Tier | Status after June 18, 2026 |
|---|---|
| Gemini Code Assist for individuals, the free tier | No longer served. Migrate to Antigravity CLI |
| Google AI Pro and Google AI Ultra | No longer served. Migrate to Antigravity CLI |
| Gemini Code Assist for GitHub | New installations halted, existing requests ceased |
| Gemini Code Assist Standard and Enterprise licenses | Uninterrupted access retained |
| Paid Gemini and Gemini Enterprise Agent Platform API keys | Uninterrupted access retained |
The security consequence is a fork. If your developers are on Standard or Enterprise licenses, Gemini CLI is still live in your estate and still needs the version floor and the settings work above. If they were on Pro, Ultra or the free tier, they have already moved, and whatever review you did of Gemini CLI does not transfer, because Google states Antigravity CLI "shares the same agent harness as Antigravity 2.0," a different codebase from the one you assessed.
Antigravity's short public security history is worth reading before you sign off on the migration. Two findings are on the record.
Secure Mode bypass leading to remote code execution. Pillar Security reported it on January 7, 2026, Google fixed it on February 28, 2026 and awarded a bounty on March 26. The technique abused the Pattern parameter of the find_by_name tool: "By injecting the -X (exec-batch) flag through the Pattern parameter, an attacker can force fd to execute arbitrary binaries against workspace files." What makes it instructive is why the strictest available setting did not help. In the researchers' words, "Find_by_name is classified as a native tool, not a shell command. Native tool invocations execute before Secure Mode's restrictions are evaluated, so the security boundary never sees the call." That is the same structural error as CVE-2026-12537: the dangerous path did not pass through the checkpoint.
Persistent code execution from a malicious workspace. Mindgard published a finding it calls Forced Descent, in which markdown rules in a project's .agent directory instruct the agent to write a malicious mcp_config.json into the global Antigravity settings directory, producing code execution on every application launch that survives uninstalling and reinstalling. Report the honesty here in full: Mindgard reported it to Google on November 19, 2025, Google closed it on November 21 as "Won't Fix (Intended Behavior)," then reopened it on November 25 after Mindgard published. We have not found a published fixed version, so treat this as open and control it by not opening untrusted repositories in an agentic IDE, which is advice you should already be following after the Cursor findings.
Two other differences matter commercially rather than technically. Antigravity CLI is not open source, where Gemini CLI was, so third-party security review of the harness is no longer possible in the same way. And migration is a real reinstall rather than an upgrade, which means it is the natural moment to apply an allowlist and a sandbox policy from the start instead of retrofitting one.
How to secure Gemini CLI and Antigravity CLI: the hardening checklist
Ordered by risk removed per hour spent. The first three are the ones that would have stopped published attacks.
- Pin the version floor in CI first. Gemini CLI 0.39.1 or later, google-github-actions/run-gemini-cli 0.1.22 or later. Grep every workflow file for the action reference and for floating tags. A workflow pinned to a mutable major tag is not pinned.
- Never run an agent with write-capable credentials against content an outsider can author. Issue bodies, pull request titles, issue comments and forked branches are all attacker-controlled input. If a triage or review workflow must read them, run it with a read-only token and no repository write scope, and require a separate human-approved job for anything that writes.
- Assume the yolo approval mode plus untrusted input equals code execution. If automation genuinely needs unattended tool calls, pair it with a sandbox and a
coreToolsallowlist, and confirm on your actual version that the allowlist is enforced, since before 0.39.1 it was not. - Enforce policy from system overrides, not from the repository. The precedence order ends at the system overrides file, so put sandbox enforcement and the tool allowlist there where a workspace settings file cannot relax them.
- Allowlist, do not blocklist. Google's own guidance is unambiguous on this and it is worth the extra week of tuning. Start from the four or five commands your workflows actually run.
- Keep folder trust enabled and trust narrowly. Trust the specific project, not the parent directory, because trusting a parent trusts everything beneath it. Never open a repository you did not review in an agentic IDE.
- Scope the secrets the agent's environment can see. CVE-2026-12537 was valuable because a CI runner's environment is full of credentials. Short-lived, narrowly scoped tokens turn host code execution from a breach into an incident.
- Inventory which tier each team is on. After June 18, 2026 this determines whether you are securing Gemini CLI, Antigravity CLI, or both at once. Most estates we see are both.
- Review MCP servers separately. Both tools load MCP configuration, and the Forced Descent finding turns global MCP config into a persistence mechanism. Allowlist servers and pin tool definitions. See MCP server security.
- Log agent tool calls somewhere the developer machine and the CI runner cannot edit. If the host is compromised, its local logs are the first artifact an attacker rewrites. See audit trail.
Steps one and two are unglamorous and produce no visible improvement, which is exactly why they are still undone in most of the pipelines we look at.
What a runtime control point does and does not fix for coding agent CLIs
We sell an agent policy layer, so read this table skeptically. It is written to be accurate rather than flattering, and the first three rows are a flat no.
| Gemini CLI or Antigravity CLI risk | Does an agent control point help? | What actually fixes it |
|---|---|---|
| CVE-2026-12537, pre-sandbox command execution in the container launcher | No. That code runs before any agent request exists, so there is nothing for a policy layer to evaluate | Upgrading to 0.39.1 and run-gemini-cli 0.1.22. A version bump, nothing else |
| The Antigravity Secure Mode bypass through the find_by_name tool | No. That is a flaw inside the vendor's own tool dispatch, below anything we sit on | Google's February 2026 fix. Stay current on the IDE and CLI build |
| Stopping developers from pasting proprietary code into a model | No, and you probably do not need it here. Under Gemini Code Assist Standard and Enterprise, Google states inputs and outputs are not used to train shared models | The licensing tier itself, plus your acceptable use policy. Read the data governance terms, not a vendor summary of them |
| Prompt injection arriving through a GitHub issue, a scraped page or a file the agent reads | Partly. We inspect untrusted content before an agent acts on it, and no filter is complete. The Pillar payload succeeded precisely because it never used the words a filter looks for | Containment over detection: assume it lands, then constrain what the agent can do next. See prompt injection protection |
| A hijacked agent reading credentials and calling a tool it was technically allowed to call | Yes. This is the actual enforcement point, and it is where every published chain ends | A per-agent scoped identity with a default-deny tool policy applied at the call, not at the prompt. See tool permissions |
| An irreversible action: a push to main, a production deploy, a deletion, an outbound message | Yes. Held for human approval based on what the action is, not on how the request was phrased | An approval gate on the action path. See human in the loop AI agents |
| No trustworthy record of what the agent did during an incident | Yes. An append-only record of requested, allowed and denied calls, held off the developer machine and off the runner | An audit trail the compromised host cannot edit, which is usually the only artifact that survives it |
Three flat no, one partly, three yes. If you are running a vendor evaluation, ask every vendor in this market for the same table and treat an all-green answer as a reason to look harder rather than a reason to shortlist. Our survey of who genuinely does what is in AI agent security companies.
The honest summary of Gemini CLI security: Google built better controls than most agent vendors, documented their limits more candidly than most agent vendors, patched a maximum-severity flaw quickly, and still shipped two separate defects where the dangerous path ran before the checkpoint that was supposed to see it. That is not a Google problem. It is what happens when a language model is given a shell, and it recurs identically in Claude agent security, Cursor and every other tool in coding agent security. The durable control is not a smarter filter in front of the model. It is a narrow, enforced boundary around what the agent may do once the model has already been convinced.
FAQ
Common questions about gemini cli security.
Is Gemini CLI secure?
On version 0.39.1 or later, with sandboxing enforced and a tool allowlist, it is reasonable for enterprise use. Google ships trusted folders, container sandboxing, approval modes and admin-enforced settings. Google also states these "should not be considered a foolproof security boundary" against a user with local administrative rights, which is an accurate caveat worth repeating to anyone treating the sandbox as containment.
What is CVE-2026-12537?
A critical OS command injection in the Gemini CLI container launcher, scored 10.0 on CVSS v4.0. On headless CI platforms an unprivileged attacker could achieve pre-sandbox host-level code execution through a maliciously crafted .gemini/.env file. It affects Gemini CLI before 0.39.1 and run-gemini-cli before 0.1.22, and it is fixed in 0.39.1 and 0.1.22 respectively.
What version of Gemini CLI is safe?
Run Gemini CLI 0.39.1 or later, or 0.40.0-preview.3 on the preview channel, and google-github-actions/run-gemini-cli 0.1.22 or later. That floor closes both defects in the April 2026 advisory: automatic folder trust in headless mode, and tool allowlists being ignored under the yolo approval mode.
Is Gemini CLI safe to use in CI/CD?
Only with the patched versions and a narrow token. CI is where CVE-2026-12537 was most dangerous, because headless runs auto-trusted the workspace and runner environments carry credentials. Run agent workflows with read-only repository scope, never let one read attacker-authored input while holding write permissions, and require a separate approved job for anything that writes.
What is Gemini CLI YOLO mode and is it safe?
YOLO mode, set with --yolo or --approval-mode=yolo, auto-approves every tool call instead of prompting. It enables the Docker sandbox by default, which helps. It is safe only against input you control. Combined with untrusted content it is the shortest published path to code execution, and before 0.39.1 it silently ignored tool allowlists you had configured.
What are trusted folders in Gemini CLI?
A gate controlled by the security.folderTrust.enabled setting that asks you to approve a folder before the CLI loads project-specific configuration. Until a folder is trusted the CLI ignores its .gemini/settings.json and .env files, blocks extension install, update and uninstall, disables tool auto-acceptance, and disables automatic memory loading. Trusting a parent folder trusts every subdirectory beneath it.
Is Gemini CLI being discontinued?
For consumer tiers, yes. Google announced the transition to Antigravity CLI on May 19, 2026, and on June 18, 2026 Gemini CLI stopped serving Gemini Code Assist for individuals, Google AI Pro and Google AI Ultra. Organizations on Gemini Code Assist Standard or Enterprise licenses, and holders of paid Gemini or Gemini Enterprise Agent Platform API keys, retain uninterrupted access.
Is Antigravity CLI more secure than Gemini CLI?
Not demonstrably. It is a different harness, not a hardened version of the same one, so prior assessments do not carry over. Pillar Security showed a prompt injection reaching arbitrary code execution through Antigravity file search that bypassed Secure Mode entirely, fixed in February 2026. Antigravity CLI is also not open source, so independent review of the harness is harder.
Does the Gemini CLI sandbox stop prompt injection?
No. The sandbox limits the blast radius of commands the agent runs, which is valuable, but it does not prevent an injected instruction from being followed. CVE-2026-12537 executed before the sandbox started, and the Antigravity finding executed through a native tool that ran before Secure Mode evaluated it. Containment and prevention are different controls.
Does Google use my code to train models with Gemini CLI?
Under Gemini Code Assist Standard and Enterprise, Google states that prompts and responses are not used to train those models, and that customer code, inputs and generated recommendations are not used to train shared models or develop other products. Consumer tiers had different terms and are no longer served by Gemini CLI anyway. Verify the current data governance terms for your specific license.
What is the difference between GeminiJack and the Gemini CLI vulnerability?
They are different products. GeminiJack, disclosed by Noma Labs, was a zero-click indirect prompt injection in Gemini Enterprise and Vertex AI Search that exfiltrated Gmail, Calendar and Docs content through a poisoned document. CVE-2026-12537 was OS command injection in the Gemini CLI container launcher on CI runners. Same attack class, different surfaces, separate fixes.
Do I still need an agent security layer if I use Gemini CLI sandboxing?
Only if your agents act on systems that matter. Sandboxing plus an allowlist is sufficient for an agent editing files in a disposable container. If the agent pushes to repositories, calls internal APIs, triggers deploys or touches a system of record, those actions need authorization and an audit record enforced where the call is made, not where the prompt was read.
More use cases