Repository navigation
bug(core): findUntrustedFlags still breaks YOLO mode on project temp dir paths, workspace .sh scripts, ~/ paths, and lacks a settings toggle (even after #29833) #30004
Description
What happened?
In --yolo mode (--approval-mode=yolo), Gemini CLI repeatedly interrupts autonomous execution with:
⚠️ CRITICAL SECURITY WARNING: Untrusted Command Flags Detected
The following flags/arguments were sourced from external untrusted input (e.g., Buganizer ticket, external document):
• /Users/<user>/.gemini/tmp/<session>/parse_pr.py
Allow execution of [Shell]?
● 1. Allow once
2. No, suggest changes (esc)
Even after PR #29672 (in v0.65.0/v0.66.0) and PR #29833 (on main), packages/core/src/utils/untrustedContextTracker.ts and scheduler.ts still cause false positives that break --yolo mode in normal developer workflows:
-
Check 2 (non-flag path arguments) still matches against ALL local
run_shell_commandoutput (untrustedTokens/untrustedTexts), notexternalTokens, and rejects Gemini CLI's own project temp dir (~/.gemini/tmp/<session>/):- When the agent writes a temporary helper script to its own project temp dir (e.g.
/Users/<user>/.gemini/tmp/42/parse_pr.py) and runs it viarun_shell_command, any output containing that path (such as a Python tracebackFile "/Users/.../.gemini/tmp/42/parse_pr.py", line 3) is wrapped in<untrusted_context>and indexed intountrustedTokensanduntrustedTexts. - On the next run (
python3 /Users/.../.gemini/tmp/42/parse_pr.py), Check 2 checksisHighRiskPatternToken(token) && !isWorkspaceLocalPath(token, options). - Because
~/.gemini/tmp/<session>(and/tmp) is outsideWorkspaceContext.isPathWithinWorkspace(),isWorkspaceLocalPath()returnsfalse, and Check 2 checksuntrustedContext.untrustedTokens(notexternalTokens), flagging the agent's own temp file as untrusted input.
- When the agent writes a temporary helper script to its own project temp dir (e.g.
-
isWorkspaceLocalPath()unconditionally rejects.shscripts and~/$VARpaths even inside the workspace:EXECUTABLE_SCRIPT_REGEX.test(token) || /[$`~]/.test(token)
- Running a workspace script like
./scripts/build.shafter it appeared ingit statusorlsoutput triggersUntrusted Command Flags DetectedbecauseEXECUTABLE_SCRIPT_REGEXforcesisWorkspaceLocalPath()to returnfalse. - Any path using
~or$HOMEtriggers the warning because/[$~]/forcesisWorkspaceLocalPath()to returnfalse`.
- Running a workspace script like
-
REMOTE_CONTENT_COMMAND_ROOTS(gh,curl,ssh,wget) tags entire CLI outputs assource="shell_remote"(externalTokens):- In standard GitHub / CI workflows (
gh pr view,gh api,curl,ssh), every word, branch name, path, and flag in the output is added toexternalTokens, causing subsequent shell commands in the same session to trigger false-positive security prompts.
- In standard GitHub / CI workflows (
-
No configuration setting in
settings.jsonto disablehasTaintedOrBuildFileRiskoverride in--yolomode:scheduler.tsunconditionally overridesdecision === "allow"to"ask_user"(or"deny"in headless mode) whenhasTaintRiskis true, with no setting (e.g.security.disableUntrustedFlagsCheckorsecurity.allowUntrustedFlagsInYolo) for users who explicitly opt into--yolo.
What did you expect to happen?
Check 2(non-flag path arguments) should only match againstexternalTokens(orisWorkspaceLocalPathshould also trustconfig.storage.getProjectTempDir()and/tmpfor local shell output).- Workspace-local scripts (
./scripts/*.sh) that only appeared in local shell output (ls,git status, stack traces) should not be flagged as untrusted external input. - Provide a
settings.jsonoption (e.g.,security.enableUntrustedFlagsCheck: false) so users running in--yolomode can disable the taint-check override without having to monkey-patchfindUntrustedFlagsinbundle/chunk-*.json every update.
Client information
- CLI Version: 0.66.0
- Operating System: darwin (macOS arm64, Node.js v24.18.1)
- Sandbox Environment: no sandbox
- Approval Mode: yolo
Login information
Google Account (OAuth)
Anything else we need to know?
Related issues / PRs:
- Gemini CLI v0.63.0 - breaks yolo mode #29682
- The recent 'Untrusted Command Flags' security warning completely breaks YOLO mode and makes the CLI unproductive compared to Claude Code, as it constantly interrupts for basic file operations when using MCP servers. #29680
- fix(core): scope untrusted flag checks to external output and remember approved flags #29833
Current local workaround required on every npm update: patching function findUntrustedFlags(command, untrustedContext) { return []; in bundle/chunk-*.js.
Activity
npu-sword commentedon Oct 28, 2026
It's been weeks that this very annoying bug is around. I blocked autoupdate and stick to version 0.61 and waiting that something is done to make the YOLO mode YOLO and not bother you 30 times a day for false positives.
The priority of this issue should be P1 @gemini-cli-robot can you increase the severity of this issue ?