Calendar Icon White
November 24, 2026
Clock Icon
8
 min read

Gemini CLI Security: What to Block and Why

Gemini CLI reads files, runs commands and calls MCP servers on your machine. The paths worth blocking, how its hook layer works, and what Google Workspace admin visibility does not extend to.

Gemini CLI Security: What to Block and Why
ChatGPT
Perplexity
Grok
Google AI
Claude
Summarize and analyze this article with:

TL;DR

Gemini CLI is a terminal coding agent with filesystem, shell and MCP access. The controls are the same family as every other agent on this list, and there is one thing genuinely specific to it worth knowing.

The mechanism itself, including the exit codes and a working script, is on Claude Code hooks and runs in Gemini CLI with the same logic. This page covers what is specific to Gemini CLI.

What is different about Gemini CLI

Gemini CLI tends to sit on machines that are already deep in Google Workspace, which creates a particular shape of risk: ~/.config/gcloud/ is very often populated with credentials that reach real projects, and an agent with filesystem access on that machine is one read away from them. Put the gcloud config directory at the top of the blocklist rather than halfway down it.

The second consequence is that Workspace admins often assume their existing visibility covers this. It does not, for the reason in the next section.

✨ Where the checkpoint sits

Diagram of a PreToolUse hook between an agent and its tool call
The same checkpoint in Gemini CLI: the agent asks, your code decides, the call runs or it does not.

Gemini CLI supports this from version 0.27.0. The event names and the config file differ between agents; the decision point does not.

AgentMinimum versionNotes
Claude Code2.1.296The reference implementation. PreToolUse, PostToolUse, UserPromptSubmit and the rest.
Cursor1.7.0Reads Claude Code's hook format and maps it onto its own events.
Codex0.145.0Its own hook layer with equivalent before and after points.
GitHub Copilot CLI1.0.57Hook support on the CLI surface.
Gemini CLI0.27.0Hook support on the CLI surface.
Windsurf3.5.17Ships a hook layer that is off by default.

✨ What the Gemini CLI admin surface cannot tell you

Google Workspace admin gives you OAuth token inventory and audit for things that authenticate to Google. A CLI agent reading a local file, running a local command or calling a local MCP server produces no Workspace event, because nothing touches Google. The coverage is real but it stops at the network boundary.

Strac Shadow AI discovery showing Gemini CLI and other agents across the fleet
Gemini CLI alongside the other coding agents on the fleet, with the devices, users and MCP servers attached to each.

✨ The MCP side

Gemini CLI can call MCP servers, which means its reach is whatever is in the config rather than just the repository. A server pointed at production is a production credential sitting on a laptop, and a file-path control never sees it.

Strac MCP server inventory with approve and disallow controls
Every MCP server the fleet's agents can call, approved or disallowed, with the agents using each one.

Where Gemini CLI keeps its configuration

Gemini CLI reads ~/.gemini/settings.json for user settings and .gemini/settings.json inside a project. Both are worth inventorying, and the project-level file is the one that gets missed, because it travels with the repository and can arrive on a machine without anyone deciding to put it there.

A project-level settings file committed by a well-meaning colleague can add MCP servers to every clone of that repo. That is a supply-chain shaped problem wearing configuration clothes, and it is specific enough to Gemini CLI and its peers to be worth a line in your review checklist.

A worked example

A data engineer asks Gemini CLI to explain why a pipeline is failing in a Google Cloud project. The agent reads the repo, then reads ~/.config/gcloud/ to understand which project is configured. Those files hold refresh tokens for a principal that can read production buckets.

Nothing in Workspace audit records this, because nothing authenticated to Google: the agent read local files. The gcloud directory belongs at the top of the blocklist on exactly the machines where Gemini CLI is most popular.

Three mistakes teams make with Gemini CLI

Assuming Workspace coverage extends to the laptop. OAuth inventory and audit are good, and they stop where the network stops. Local reads and local commands are invisible to them.

Leaving the gcloud directory off the list. It is frequently populated with live credentials and is often ranked below .env out of habit. On these machines it should be above it.

Ignoring project-level settings files. They travel with the repo and can introduce MCP servers nobody on your team chose.

✨ What you can actually evidence

Workspace admin answers "what touched Google". A complete answer to "what did the agent reach" needs local evidence as well, typed by data class rather than arriving as a flat stream of events.

Strac findings broken down by secrets, PII, card data, health data and source code
Findings typed by data class rather than arriving as undifferentiated alerts, which is the difference between a log and an answer.

Rolling it out

ModeThe developer seesPromote when
MonitorNothing. The event is recorded.You are still learning what normal looks like.
AskA prompt, with the option to proceed.The rule is usually right but edge cases exist.
BlockThe call is stopped and the agent told why.The rule is unambiguous. Credentials belong here.

Related reading: AI coding agent security, Claude Code hooks, Windsurf security, stop agents reading secrets, Cursor security, Codex security.

For the local activity Workspace audit does not cover, Strac's coding agent security integration captures reads, commands and MCP calls on the machine itself.

🌶️ Spicy FAQs

Is Gemini CLI safe for enterprise use?

Yes, with the same scoping every coding agent needs: block credential reads, decide which MCP servers it may call, and know which machines it is on. The agent is not the risk; the unscoped filesystem and shell access is.

What should I block first in Gemini CLI?

The gcloud configuration directory, ~/.config/gcloud/, before anything else. On machines where Gemini CLI is popular it is usually populated with credentials that reach live projects. Then the normal set: .env, SSH keys, kube config.

Does Google Workspace admin show me what the agent did locally?

No. Workspace audit covers what authenticates to Google. Local file reads, local shell commands and local MCP calls generate no Workspace event. Local activity needs an endpoint-side source.

Does Gemini CLI support hooks?

Yes, from version 0.27.0 on the CLI surface. Same decision point as the other agents, different registration.

Can I use one script across Gemini CLI and Claude Code?

The deciding logic ports cleanly, since both hand you the pending call and read an exit code. The registration does not, so each agent needs its own config entry pointing at the same script.

Last updated: November 24, 2026

Customer story

“Don’t just alert on problems, fix them.”

Scott Roberts, Chief Information Security Officer, UiPath

  • UiPath
  • Crypto.com
  • Inmar Intelligence
  • thredUP
  • Paymentology
  • Enveda
  • Genesis Molecular AI
  • MeridianLink
More customer stories →
Is Gemini CLI safe for enterprise use?
What should I block first in Gemini CLI?
Does Google Workspace admin show me what the agent did locally?
Does Gemini CLI support hooks?
Can I use one script across Gemini CLI and Claude Code?
Discover & Protect Data on SaaS, AI, MCP, Endpoints & Cloud
Strac provides end-to-end data loss prevention for all SaaS and Cloud apps. Integrate in under 10 minutes and experience the benefits of live DLP scanning, live redaction, and a fortified SaaS environment.

Customers include

  • UiPath
  • Crypto.com
  • Inmar Intelligence
  • thredUP
  • Paymentology
  • Enveda
  • Genesis Molecular AI
  • MeridianLink
Trusted by enterprises
Data Security + Compliance Automation

Latest articles

Browse all

Get Your Datasheet

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Close Icon