gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Folder Trust ships disabled by default — is honoring a cloned repo's .gemini/settings.json (incl. trust:true MCP servers) the intended default posture?

Open NagaYu opened this issue 1 week ago • 7 comments

I built RepoGrant, an offline verifier that computes the effective authority a repository's agent configuration grants, per tool, under each tool's documented semantics. Part of the work is a pinned audit of the tools' documented defaults (Claude Code, Codex, Cursor, Copilot, Gemini CLI), and one Gemini CLI entry stands out as worth asking about directly.

Per the docs (Trusted Folders):

"The Trusted Folders feature is disabled by default."

With the feature on, an untrusted folder gets a safe mode:

"Workspace settings are ignored: The CLI will not load the .gemini/settings.json file from the project." "Environment variables are ignored: … not load any .env files"

But because the feature is off by default, by default a cloned repository's .gemini/settings.json and .env are honored — the safe mode only exists once a user has opted in. This composes with one more documented default: an mcpServers entry in that same settings file can set trust: true, which per the configuration reference "bypasses all tool call confirmations for this server". So on a default install, cloning a repo can mean its committed MCP server runs tool calls with no confirmation, and no trust prompt ever appears, because the trust layer itself is opt-in.

For scale: in a field audit of 120 public repositories carrying agent configs (aggregates published in the RepoGrant repo), 26 carried .gemini/settings.json — every one of them in the honored-by-default class on a default install. Neighbouring tools put repo-carried config behind some form of trust decision (e.g. Codex reviews repo hooks per-hash before they run), which is what made this default read as a possible outlier rather than a convention.

Question: is disabled-by-default the intended posture — i.e., is safe mode meant as an opt-in hardening step, with cloned-repo config honored by default? If this was already discussed and decided, a pointer is enough and I'll update RepoGrant's defaults matrix to cite the decision. If it wasn't a deliberate trade-off, the settings documentation may be the cheapest place to surface it.

The full semantics register behind this (verbatim quotes + citations for all five tools) is in the repo: https://github.com/NagaYu/repogrant/blob/main/SEMANTICS.md — happy to be corrected if any of it misreads the docs.

NagaYu avatar Nov 20 '26 16:11 NagaYu

There is a problem with the Gemini CLI issue triaging. Please check the action logs for details.

gemini-cli[bot] avatar Nov 20 '26 16:11 gemini-cli[bot]

The composition is the real question, and it is worth separating the two knobs.

Honoring repo-carried mcpServers is one decision. trust: true in that same file skipping every confirmation is another. Together they mean a clone can grant unattended execution of an arbitrary command with no prompt, on a default install. Each default is defensible alone; their product is the outlier you measured.

Flipping Trusted Folders on by default is probably the wrong lever, because it also stops .env loading and changes behaviour for every existing user. The narrower fix is a decision on the first repo-carried mcpServers entry: prompt with the server name, transport and command, persist the answer against a hash of that entry, and show trust: true verbatim in the prompt instead of letting it pre-answer.

That mirrors how Codex reviews repo hooks per entry, and leaves folder trust to do the job it was designed for.

media-ctrl avatar Nov 26 '26 12:11 media-ctrl

Thank you — this separation is the right one, and I agree with it. What the measurement behind this issue captures is the composition, not either default alone: in a field audit of 120 public repos, the recurring pattern was exactly this pairing — a repo-carried config honored silently, plus a setting in the same file that pre-answers the confirmation. Each looks reasonable in isolation; the effective authority only appears when the two are evaluated together.

The narrower fix you describe is the one the data supports. A first-use decision per mcpServers entry — persisted against a hash of the entry, and showing trust: true verbatim instead of letting it pre-answer — breaks the composition without changing folder-trust behaviour for everyone else, including .env loading. The Codex per-entry review is a good precedent for the shape.

If it helps anyone implementing this, the per-tool breakdown of which config surfaces compose this way (Claude Code, Codex, Cursor, Copilot, Gemini CLI) is in the RepoGrant bench, and I can pull the Gemini CLI rows into this thread.

NagaYu avatar Nov 26 '26 13:11 NagaYu

Agreed on the shape. One detail decides whether it holds up in practice: what the hash covers.

Key the persisted approval on the whole settings.json and every unrelated edit invalidates prior decisions, so users learn to click through prompts. Key it on the entry name alone and a changed command or args reuses an approval granted for something else. Hashing the entry key plus transport, command and args, independent of the surrounding file, gives a decision that survives cosmetic edits and does not survive a swapped command.

Two consequences worth stating in the fix: an entry whose hash changes must fall back to unapproved instead of inheriting the old decision, and the prompt should render resolved values rather than raw JSON, so trust: true appears as its effect and not as a line to skim past.

Yes please on the Gemini CLI rows. The per-tool comparison is the part that makes a narrow change arguable, because it shows the neighbouring defaults on the record instead of asserting this one is odd.

media-ctrl avatar Nov 26 '26 13:11 media-ctrl

Agreed on the hash scope, and on both consequences. Keying on the entry (key + transport + command + args), independent of the file, is also how RepoGrant evaluates an entry's effective authority — the file is the carrier, not the grant. And yes: a changed hash must mean unapproved, not inherited; and the prompt should show the resolved effect ("this server will run tool calls without confirmation") rather than a JSON line.

Here are the Gemini CLI rows from the register (SEMANTICS.md §5; documented semantics, verbatim sources in the repo):

Dimension Gemini CLI
Repo settings .gemini/settings.json; precedence: defaults < system defaults < user < project < system < env < CLI args
Approval default general.defaultApprovalMode = "default" (prompts); YOLO is CLI-only
Folder Trust Feature "disabled by default"; safe mode (workspace settings and .env ignored) applies only once enabled — so repo settings and .env are honored by default
MCP launch mcpServers in the same settings file (command, args, env)
trust trust: true "bypasses all tool call confirmations for this server" (field default false), honored from the repo-carried file
Silent network egress not-judgeable — the tools.sandbox default is not documented verbatim (tools.sandboxNetworkAccess defaults false)

Field audit (120 public repos carrying agent configs): 26 carried .gemini/settings.json, every one in the honored-by-default class on a default install.

The neighbouring defaults, for the record: Claude Code gates project MCP servers behind approval ("a cloned repository can't approve its own servers") and ignores enableAllProjectMcpServers in untrusted folders; Codex loads project config only for trusted projects and records hook trust per hash; Cursor asks for approval before MCP tool use by default. Of the five, Gemini CLI is the only MCP surface where one repo-carried file can both declare the server and pre-answer its confirmations on a default install.

NagaYu avatar Nov 26 '26 13:11 NagaYu

The register gap that matters is confinement, not egress. With confirmations pre-answered by trust: true, a repo-carried mcpServers command runs as the user; the sandbox decides how confined that run is, not whether it happens. So tools.sandboxNetworkAccess being undocumented does not leave the composition indeterminate, it leaves the confinement row blank, which is the row a maintainer can act on.

It is worth its own row next to silent network egress, because the two fail independently: a documented egress default cannot compensate for an undocumented confinement default. That also keeps the register honest where the product is weakest without requiring anyone to settle the broader Trusted Folders question first.

media-ctrl avatar Nov 26 '26 13:11 media-ctrl

Accepted — the blank belongs on the confinement row, not the egress row. To be precise about what is undocumented: the egress default is documented (tools.sandboxNetworkAccess defaults to false); what has no documented default is tools.sandbox itself — whether a pre-approved command runs sandboxed at all. With trust: true the run happens as the user either way, so that default is the whole confinement story, and you are right that it fails independently of the egress row.

I'll split the two in the register: egress = documented (false); confinement = not-judgeable, as its own row. That is also the more useful shape for a maintainer — filling the confinement cell does not require settling the Trusted Folders question.

NagaYu avatar Nov 26 '26 14:11 NagaYu