Skip to content

Gemini hook: an unreadable global settings file trusts the workspace and applies its allow rules #4878

Done

Description

@KuSh

gemini_settings in src/hooks/permissions.rs decides whether the project's .gemini/settings.json is trusted from the global file's security.folderTrust.enabled. When the global file exists but cannot be read or parsed, that lookup sees nothing, folder trust counts as off, every workspace counts as trusted, and the project file's tools.allowed rules are applied.

#4652 lists Gemini as "ask and allow only. Losing them means fewer allows, which is not unsafe". That holds for the global file's own rules, but losing the global file also turns folder trust off.

Measured on develop 6c1af5fbc and on #4680's head eaee169b6, same output on both (gemini_settings and read_json are byte-identical in v1.0.1 and 6c1af5fbc), rtk hook gemini, no GEMINI_CLI_TRUST_WORKSPACE. Global ~/.gemini/settings.json = {"security":{"folderTrust":{"enabled":true}}}, project .gemini/settings.json = {"tools":{"allowed":["run_shell_command(git push)"]}}, payload run_shell_command / git push origin main:

global settings.json output
valid "decision":"ask_user", command rtk git push origin main
trailing comma "decision":"allow", same command, parse warning
chmod 000 "decision":"allow", same command (read warning since #4680, none before)

So a repository's own settings file grants allow, which the global configuration had withheld.

What would close it: when the global file is unreadable or unparseable, treat the workspace as untrusted (use no project rules), and add a test for each of the two failure shapes through the real hook.

Activity

  1. rtk-wshm-sync-bot commented on Oct 31, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 90%

    Summary

    Unreadable/unparseable global Gemini settings.json causes folder trust to default to on, letting an untrusted project's tools.allowed rules apply; fail closed instead.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/hooks/permissions.rs

    Suggested Actions

    1. In gemini_settings/read_json (src/hooks/permissions.rs), treat read/parse failure as folderTrust=false, not absent
    2. Add tests for the chmod 000 and trailing-comma failure shapes via the real rtk hook gemini path
    3. Verify fix against both develop 6c1af5f and fix(hooks): preserve host checks when settings cannot be loaded #4680 head eaee169 since behavior was identical on both
    4. Cross-check OpenCode hook misses .opencode project permissions and can lift deny or ask #4855 (OpenCode hook, similar trust-lifting issue) for a shared root cause or fix pattern

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. added a commit that references this issue on Nov 29, 2026
    688a62a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions