Gemini CLI Security Fundamentals (as of 01 Aug 2026)

Grading note. A dated snapshot — accurate as of 01 Aug 2026, frozen here and kept as a permanent archive entry. Research-drafted by a pupil, graded by the 3-lens panel + sensei. Corrections applied inline; unverifiable gaps marked ⚠ PENDING (#issue) — never guessed.

Prerequisite: Gemini CLI is Google’s open-source, terminal-based AI coding agent. Install it with npm install -g @google/gemini-cli (requires Node.js already installed). Check your installed version any time with gemini --version; upgrade with npm install -g @google/gemini-cli@latest. This entry assumes you already have it installed and are picking your safety settings.

How to read the labels

Where settings live: most practices below tell you to edit settings.json (project-level: <project>/.gemini/settings.json; user-level: ~/.gemini/settings.json). If the file doesn’t exist yet, create it with {} as the starting content, then add keys inside the braces, e.g. {"security": {"folderTrust": {"enabled": true}}}. Commands written as /settings set ... or /permissions are slash commands — type them inside a running gemini session, not in your regular terminal.


Practice: Know exactly what each approval mode does before you pick one — plan is the SAFEST mode, not a fourth semi-autonomous one

Do: Gemini CLI has four approval settings and they are NOT interchangeable: default prompts you before every tool call (file edit or shell command); auto_edit auto-approves file-edit tools (write_file, replace) but still prompts for shell commands; plan is a read-only mode — the model can read files and draft a plan, but cannot write files or run shell commands while you’re in it; when you choose to execute the plan you’re explicitly asked to pick “Yes, automatically accept edits” (switches to auto-approve for the rest of the session) or “Yes, manually accept edits” (keeps per-action prompts) — plan mode itself never silently executes anything on its own. yolo (--yolo / --approval-mode=yolo) auto-approves everything, including arbitrary shell commands, with no per-action confirmation. Set the default with /settings set general.defaultApprovalMode <mode> (a slash command, typed inside gemini) or edit general.defaultApprovalMode directly in settings.json. Only yolo cannot be set via settings.json — it must be invoked explicitly via flag or slash command. Why (beginner): New users often assume plan's name implies it’s a semi-autonomous mode — it’s actually the safest mode: read-only until you personally approve execution. Separately, auto_edit is not the safe middle ground it sounds like either: it still lets the agent run any shell command it wants without asking — only file writes are gated. If you want a genuine “look before every step” experience, use default. Caveat / contested: Official docs document only three CLI-flag modes (default, auto_edit, yolo) on the configuration reference page; plan mode is documented separately with its own safety framing (“enforces strict safety policies to prevent accidental changes,” “a read-only environment for architecting robust solutions before implementation”). Cite each doc for its own claims — the configuration reference alone doesn’t describe plan mode’s behavior. Sources: geminicli.com/docs/reference/configuration/ (fetched 01 Aug 2026) · github.com/google-gemini/gemini-cli — docs/cli/plan-mode.md (fetched 01 Aug 2026) Confidence: vendor-documented


Practice: Treat --yolo as “no seatbelt” — restrict it to disposable/CI sandboxes with fully-trusted, non-public input, never real work

Do: --yolo (or --approval-mode=yolo, or the in-session Ctrl+Y toggle) removes the confirmation prompt for every tool, including run_shell_command. Independent write-ups describe this as removing “one of the biggest built-in safeguards” — if you tell the agent to do something destructive it does it immediately with no “are you sure?” Use YOLO only in throwaway VMs, disposable containers, or CI jobs that process fully-trusted, non-public input — never on a machine with data, credentials, or production access you care about, and never in CI that reacts to public issues, PRs, or webhooks (see the CVE practice below: a public-issue-triage bot in --yolo mode is exactly the configuration that produced a CVSS-10.0-rated CI/CD RCE). Teams should disable it centrally (see the enterprise-lockdown practice below) rather than trust everyone to remember --yolo is dangerous. Why (beginner): This is the single most common way beginners lose files or run something destructive with an AI CLI tool: they turn on “auto-approve everything” to stop the prompts, then the agent runs a command it misread from a file, from a compromised dependency, or — for a CI bot — from a public issue or PR someone else wrote. There is no confirmation step to catch it. “It’s just a bot reading issues” does not make the input trusted. Caveat / contested: ⚠️ WARNING — YOLO mode auto-enables sandboxing by default (see next practice), which reduces but does not eliminate the blast radius; it is still not equivalent to “safe.” The April 2026 CVE below showed that even YOLO’s tool allowlists could be silently bypassed in CI on versions before the patch, so “I scoped YOLO to safe tools” was not a safe assumption pre-patch. Sources: geminicli.com/docs/reference/configuration/ (fetched 01 Aug 2026) · devsolus.com — Gemini CLI Permissions: Is YOLO Mode Safe? (10 Jul 2025) · penligent.ai — Gemini CLI RCE, Workspace Trust and the CI/CD Agent Attack Surface (28 Apr 2026) Confidence: independently-corroborated


Practice: Sandboxing is opt-in, not automatic — turn it on and pick the strongest option your OS supports

Do: Gemini CLI does NOT sandbox shell/file operations by default in normal interactive use; you must enable it with -s/--sandbox, the GEMINI_SANDBOX env var, or "sandbox": true in settings.json (it auto-enables only when you use --yolo/--approval-mode=yolo). Concrete minimum: run gemini --sandbox — on macOS this uses the built-in Seatbelt profile with no extra install; on Linux/other platforms it uses a Docker or Podman container, which you must already have installed and running (Gemini CLI does not install a container runtime for you). Isolation strength varies a lot by backend: macOS sandbox-exec (Seatbelt) is the lightest — its default permissive-open profile confines writes to the project directory but still allows broad file reads and network access; Docker/Podman container sandboxing is stronger and cross-platform; gVisor (runsc, Linux-only) is described by Google as the strongest available isolation, running containers inside a user-space kernel, but it isn’t auto-detected and must be explicitly configured. There’s also a separate, narrower security.toolSandboxing setting (default false) that isolates individual tool calls rather than the whole CLI process — don’t confuse it with the main sandbox. Why (beginner): People assume “it’s an AI coding agent from Google, surely it’s sandboxed by default” — it isn’t, in the common case of just running gemini interactively. If you’re letting the agent run shell commands against real project files, turn on at least Seatbelt/Docker sandboxing; don’t rely on the confirmation prompts alone. Caveat / contested: ⚠️ WARNING — even sandboxed, the default macOS profile still permits network egress and broad reads, so a sandbox escape or a malicious curl isn’t stopped by the default profile; you need a *-closed/*-proxied profile or a container backend for real network isolation. An independent technical review found additional gaps as of a Feb 2026 build: custom-named credentials (not matching “TOKEN”/“SECRET” patterns) could still leak through spawned child processes, and the web-fetch tool allows arbitrary public URLs even though private IPs are blocked — both undercut a “sandbox = fully contained” mental model. As of 01 Aug 2026 the default permissive-open profile’s behavior (broad reads + network access, writes confined to the project directory) is confirmed unchanged — a 17 Jul 2026 commit reworking the Seatbelt profile implementation was an internal SBPL cleanup, not a change to default behavior. A separate, stricter deny-by-default Seatbelt mode exists as an explicit opt-in (added 18 Mar 2026) — use it if you want isolation stronger than the default profile provides. Sources: github.com/google-gemini/gemini-cli — docs/cli/sandbox.md (fetched 01 Aug 2026) · geminicli.com/docs/cli/sandbox/ (fetched 01 Aug 2026, confirms default profile unchanged) · agent-safehouse.dev — Gemini CLI Sandbox Analysis Report (12 Feb 2026, v0.30.0-nightly) Confidence: independently-corroborated


Practice: Don’t trust either of Google’s own docs on folder-trust defaults — they disagree with each other; verify or just turn it on

Do: Gemini CLI’s “Trusted Folders” feature (security.folderTrust.enabled) gates whether opening a new directory in gemini triggers a one-time approval dialog — listing any MCP servers, custom commands, hooks, and skills that folder would activate — before loading that folder’s .gemini/settings.json/.env files. ⚠️ Google’s own documentation is internally inconsistent about whether this is on or off by default: the dedicated Trusted Folders doc states it is “disabled by default,” while the settings reference table lists security.folderTrust.enabled's default as true. Don’t assume either reading — check your own installed version’s actual behavior (open an unfamiliar folder and see whether you get a trust prompt), and if in doubt, explicitly set "security": {"folderTrust": {"enabled": true}} in your user ~/.gemini/settings.json so you get the approval dialog regardless of which default your build ships with. Manage trust decisions later with /permissions; trust choices are stored in ~/.gemini/trustedFolders.json. Why (beginner): This is the config-trust trap: a project-level settings file isn’t just “project preferences” — it can define MCP servers and environment variables that run code or exfiltrate data the moment you open the folder. Because Google’s own docs disagree on the default, don’t trust either one — verify for yourself, or just turn it on explicitly so you’re not guessing. Caveat / contested: This interactive, per-folder trust prompt is a different mechanism from the headless/CI auto-trust bug described in the next practice — that bug auto-trusted workspace folders in headless/CI mode regardless of this setting, so enabling folder trust here does not by itself fix CI; for CI you need the patched CLI version (see next practice). Sources: github.com/google-gemini/gemini-cli — docs/cli/trusted-folders.md (“disabled by default”; fetched 01 Aug 2026) · geminicli.com/docs/reference/configuration/ (security.folderTrust.enabled default listed as true — contradicts the above; fetched 01 Aug 2026) Confidence: contested (Google’s own docs disagree on the default)


Practice: Patch immediately and treat headless/CI runs as high-risk — CVE-2026-12537, and a follow-up July 2026 disclosure Google chose not to fully patch

Do: In April 2026, Google fixed a maximum-severity vulnerability in @google/gemini-cli before 0.39.1/0.40.0-preview.3 and google-github-actions/run-gemini-cli before 0.1.22, tracked as GHSA-wpqr-6v78-jr5g and later assigned CVE-2026-12537 (CVE published 24 Jun 2026 — the original April write-ups predate the CVE assignment and cite only the GHSA ID; NVD and CIRCL both list the CVE and GHSA as the same underlying bug). Root causes: (1) in headless/CI mode, the CLI automatically trusted the workspace folder and loaded its config/.env files without any review — the opposite of the interactive-mode uncertainty discussed above — so an attacker who could get content into a repo (e.g. via a public GitHub issue or PR, exploiting prompt injection) could get code executed on the runner before the sandbox even initialized (execution happened pre-sandbox, so sandbox settings did not stop it); (2) --yolo mode ignored the fine-grained tool allowlists in settings.json, so a workflow that thought it had scoped shell access down was actually wide open. Upgrade to the patched versions immediately (🕒 verify live — current stable is well past the patched floor as of this writing); for CI, explicitly set trust rather than relying on defaults, strip credentials you don’t need from the job (e.g. persist-credentials: false on checkout), gate agent triggers on author association, and don’t give agent jobs write-scoped tokens for untrusted-input workflows. Why (beginner): If you wire Gemini CLI into a GitHub Action (e.g. an issue-triage bot), an anonymous person filing an issue could, on unpatched versions, have gotten your CI runner to execute their commands and steal secrets — with no login or special access needed. “It’s just a bot that reads issues” is not a safe assumption for CI agents. Caveat / contested: 🕒 The severity score is contested across scoring systems: Google’s own CNA rates it CVSS 4.0 = 10.0 CRITICAL; NIST independently scores the same bug CVSS 3.1 = 7.8 HIGH (vector AV:L, i.e. NIST judges it as requiring local rather than pure network access) — treat the patched version numbers, not either CVSS score, as the actionable fact. Separately, this April CVE is not the whole sandbox/trust story: Pillar Security’s “Week of Sandbox Escapes” series (20–23 Jul 2026, about a week before this snapshot) disclosed a new Docker-socket escape hitting Gemini CLI (since fixed) plus a macOS Seatbelt denylist bypass and a .vscode task-config bypass affecting Google’s Antigravity “Secure Mode” that Google explicitly classified as lower-severity and chose not to patch, judging it low-exploitability (requires social engineering or a trusted-repo indirect-prompt-injection setup). 🕒 verify live whether that stays unpatched. Sources: The Hacker News — Google Fixes CVSS 10 Gemini CLI CI RCE and Cursor Flaws (30 Apr 2026) · CSO Online — Max-severity RCE flaw found in Google Gemini CLI (30 Apr 2026) · SecurityWeek — Gemini CLI Vulnerability Could Have Led to Code Execution, Supply Chain Attack (7 May 2026) · Novee Security — A CVSS 10.0 in Gemini CLI: How Agentic Workflows Are Reshaping Supply Chain Risk (29 Apr 2026) · Pillar Security — My Agentic Trust Issues (5 May 2026) · penligent.ai — Gemini CLI RCE, Workspace Trust and the CI/CD Agent Attack Surface (28 Apr 2026) · NVD — CVE-2026-12537 (CVSS scoring dispute + CVE↔GHSA link; fetched 01 Aug 2026) · GitHub Advisory Database — GHSA-wpqr-6v78-jr5g (fetched 01 Aug 2026) · Pillar Security — The Week of Sandbox Escapes (Jul 2026) · Pillar Security — One Docker Socket to Rule Them All (Jul 2026) · BleepingComputer — Cursor, Codex, Gemini CLI, Antigravity hit by sandbox escapes (Jul 2026) Confidence: independently-corroborated


Practice: Turn on checkpointing before letting the agent edit real files — but know it only covers file-edit tools

Do: Checkpointing is disabled by default. Enable it in settings.json ({"general": {"checkpointing": {"enabled": true}}} — the old --checkpointing flag was removed in v0.11.0). Once on, approving a file-editing tool call (write_file, replace) makes the CLI create a Git commit in a hidden shadow repository (under your home directory / ~/.gemini/history/<project_hash>) plus a saved copy of the conversation state, so you can run /restore to list checkpoints and roll a file (and the conversation) back to that point, with the original tool call re-proposed for you to redo, edit, or skip. Why (beginner): This is your undo button for AI-made file edits — turn it on before your first real session, not after the agent has already overwritten something you wanted. It’s local-only (nothing leaves your machine) and doesn’t interfere with your project’s own git repo. Caveat / contested: ⚠ Google’s docs describe checkpoints as triggered specifically by file-editing tools (write_file, replace) and don’t state whether run_shell_command calls create a checkpoint or are covered by restore. Treat shell-command side effects (deleted files, sent network requests, installed packages) as not reliably undoable by this feature — this specific gap is not spelled out in the docs (re-checked live 01 Aug 2026, still undocumented either way), so flag it as thin/unverified rather than assuming coverage. Sources: github.com/google-gemini/gemini-cli — docs/cli/checkpointing.md (GitHub docs, last commit 10 Apr 2026) Confidence: thin


Practice: In shared/managed environments, lock YOLO mode off at the system-config level, not per-user

Do: For teams or managed machines, set security.disableYoloMode: true in a system-level settings file (/etc/gemini-cli/settings.json on Linux, C:\ProgramData\gemini-cli\settings.json on Windows, /Library/Application Support/GeminiCli/settings.json on macOS) rather than relying on individual developers to avoid --yolo. System-level settings take precedence over both user (~/.gemini/settings.json) and workspace (<project>/.gemini/settings.json) settings, so this can’t be overridden locally. Why (beginner): If you’re rolling Gemini CLI out to a team, don’t just tell people “don’t use YOLO mode” — enforce it, the same way you wouldn’t rely on everyone remembering not to sudo rm -rf. Caveat / contested: This is Google’s own enterprise-hardening recommendation; re-checked live 01 Aug 2026 — still no independent (non-Google) source discussing this specific setting, so it stays vendor-documented rather than independently-corroborated. Sources: github.com/google-gemini/gemini-cli — docs/cli/enterprise.md (GitHub docs, last commit 16 Jun 2026) Confidence: vendor-documented


Held pending fixes (not publish-ready)

CHANGELOG (grading → this entry)

  1. KILL (Skeptic): Plan mode was described as executing “every step without further prompts” — the opposite of its actual read-only, safest-mode behavior. Rewritten to correctly describe plan mode as read-only until explicit approval.
  2. KILL (Skeptic): A quote — “Google’s own guidance is that this ‘entirely disables the safety rails’” — was misattributed; the string traces to an unrelated third-party repo, not Google or either cited source. Quote removed; replaced with an accurately-sourced paraphrase from devsolus.com.
  3. KILL (Skeptic): GEMINI_YOLO=true environment variable does not exist in Gemini CLI’s documented configuration (34 env vars enumerated, none matching). Removed; replaced with the verified --yolo/--approval-mode=yolo/Ctrl+Y triggers.
  4. FIX (Skeptic): general.defaultApprovalMode citation pointed to a page that doesn’t document it. Citation swapped to the correct source page.
  5. FIX (Skeptic): Folder-trust default was stated as settled fact (“disabled by default”) when Google’s own two docs actually disagree with each other. Recast as contested with both readings shown and a “verify for yourself” recommendation; reconciled with the sibling extensions/MCP entry.
  6. FIX (Skeptic): CVE practice’s “Caveat: None found” was refuted on two counts — a real CVSS 4.0-vs-3.1 scoring dispute (10.0 vs. 7.8), and none of the six originally-cited sources actually carry the CVE ID (it postdates them). Added NVD/CIRCL citations establishing the CVE↔GHSA link and the scoring dispute.
  7. FIX (Skeptic): Root-cause attribution was backwards — the RCE was caused by headless-mode auto-trust (trust ON) plus a YOLO allowlist bypass, not by “off-by-default sandboxing/trust.” Sandbox settings are irrelevant to this exploit (execution happened pre-sandbox). Rewritten throughout, including front-matter description.
  8. FIX (Timekeeper): Added the Jul 2026 “Week of Sandbox Escapes” disclosures (new Docker-socket escape, fixed; unpatched macOS Seatbelt denylist/.vscode bypass) — material follow-up findings that postdated the original draft’s research window.
  9. FIX (Timekeeper): Resolved the “17 Jul 2026 Seatbelt refactor” held-pending item — confirmed live that it was an implementation cleanup, not a default-behavior change; default profile behavior unchanged as of this snapshot.
  10. FLAG→downgrade (Skeptic): Approval-modes practice’s independently-corroborated label rested on a single thin, outdated non-vendor source (devsolus.com predates plan mode and the current settings schema) doing too much work; downgraded to vendor-documented.
  11. Beginner-panel KILL: The YOLO-in-CI carve-out (“CI jobs that process fully-trusted input”) gave no way for a beginner to recognize their own public-issue-triage bot doesn’t qualify — exactly the setup behind the CVE below. Tightened to explicitly exclude CI reacting to public issues/PRs/webhooks, with a direct pointer to the CVE.
  12. Beginner-panel FIX: Added gemini --version / npm install -g @google/gemini-cli@latest as the standard verify/upgrade commands, referenced from the CVE practice’s 🕒 tag.
  13. Beginner-panel FIX: Sandboxing practice now gives a complete, runnable minimum (gemini --sandbox) and states the Docker/Podman prerequisite explicitly.
  14. Beginner-panel FIX: Clarified that /settings set ... and /permissions are slash commands typed inside a running gemini session, not shell commands.
  15. Beginner-panel FIX: Added a top-of-entry note on settings.json location/creation (create with {} if it doesn’t exist) so beginners don’t hand-assemble invalid JSON across four practices.
  16. Beginner-panel FIX: Added a top-of-entry prerequisite note (install command + version-check command) since none of the three drafts in this batch had previously stated how to install Gemini CLI at all.