Skip to content

fix(core): respect active YOLO mode in taint and build file checks - #30552

Open
zhoulujue wants to merge 1 commit into
google-gemini:mainfrom
zhoulujue:fix/yolo-taint-and-build-file-prompts
Open

zhoulujue wants to merge 1 commit into
google-gemini:mainfrom
zhoulujue:fix/yolo-taint-and-build-file-prompts

Conversation

@zhoulujue

@zhoulujue zhoulujue commented Nov 30, 2026 •

Copy link
Copy Markdown

Summary

(Supersedes #30268, which passed cla/google, E2E (Chained), and /gemini review with 0 issues, but was auto-closed by the 14-day lifecycle bot over the Thanksgiving weekend while waiting for help wanted / eval-gate triage.)

Respect active, trusted YOLO mode (--approval-mode=yolo / -y) in shell taint/build-file risk checks and PolicyEngine build file protection so autonomous interactive and headless (-y -p) YOLO runs are no longer interrupted by confirmation prompts or hard-denied (POLICY_VIOLATION) when editing build configuration files or running commands referencing external context (users are still hitting false-positive halts like git log -n 1 in YOLO mode on #29682).

All indirect prompt-injection protections remain fully enforced in default, auto_edit, and plan modes, in untrusted folders (!isTrustedFolder()), when YOLO mode is administratively disabled (disableYoloMode / secureModeEnabled / isYoloModeDisabled()), when safety checkers (checkerRunner) deny/ask, and when higher-tier user/admin policy rules or BeforeTool hooks explicitly require ask_user or deny.

Details

  1. PolicyEngine & Config (packages/core/src/policy/types.ts, packages/core/src/policy/policy-engine.ts, packages/core/src/config/config.ts):
    • Added optional isYoloModeDisabled?: () => boolean to PolicyEngineConfig and wired it from Config (isYoloModeDisabled: () => this.isYoloModeDisabled()), initializing this.disableYoloMode prior to PolicyEngine construction.
    • Skipped the hardcoded Build File Protection downgrade (ASK_USER / DENY on package.json, Makefile, BUILD.bazel, etc.) only when this.approvalMode === ApprovalMode.YOLO && this.isTrustedFolder() && !this.isYoloModeDisabled().
    • Explicit higher-tier ASK_USER / DENY policy rules and safety checkers continue to run unchanged.
  2. ShellToolInvocation (packages/core/src/tools/shell.ts):
    • Added isActiveYoloMode() verifying ApprovalMode.YOLO, isTrustedFolder() !== false, and !isYoloModeDisabled().
    • Updated shouldConfirmExecute() to skip forcing confirmation for hasTaintedOrBuildFileRisk() when active YOLO mode is enabled (unless forcedDecision === 'ask_user' from an explicit policy rule or hook).
    • Updated isCommandSubstitutionAllowed() so active YOLO mode delegates command substitution checks to PolicyEngine (yolo.toml sets allowCommandSubstitution = true) rather than unconditionally blocking on hasTaintedOrBuildFileRisk().
    • Preserved the hasTaintedOrBuildFileRisk() guard in getPolicyUpdateOptions() so tainted commands never persist permanent "Always allow" rules.
  3. Scheduler (packages/core/src/scheduler/scheduler.ts):
    • Skipped escalating PolicyDecision.ALLOW to ASK_USER (interactive) or DENY (non-interactive/headless) for hasTaintedOrBuildFileRisk() only when ApprovalMode.YOLO, isTrustedFolder() !== false, and !isYoloModeDisabled().

Security Invariants Preserved

Context Taint / Build-File Protection
default / auto_edit / plan modes Enforced (ASK_USER / DENY in headless)
Untrusted folder (!isTrustedFolder()) Enforced even if approvalMode === YOLO
Admin-disabled YOLO (disableYoloMode / secureModeEnabled) Enforced across PolicyEngine, Scheduler, and ShellToolInvocation
Explicit higher-tier user/admin ASK_USER / DENY rules or BeforeTool hooks Enforced in active YOLO mode
"Always allow" policy persistence for tainted commands Still blocked (getPolicyUpdateOptions() returns undefined)
Trusted, active --yolo / -y (interactive & headless -p) Allowed per yolo.toml without hardcoded interruption

Design note for maintainers: Happy to switch this to an explicit opt-in security.* setting (instead of default behavior in trusted YOLO mode) if maintainers prefer keeping taint/build-file prompts on by default in YOLO.

Related Issues

Fixes #30004
Related to #29682, #29680, #29687
Supersedes #30268

How to Validate

  1. Run targeted core unit tests (including PolicyEngine, Config, ShellToolInvocation, Scheduler, and shell utils):
    npm test -w @google/gemini-cli-core -- src/policy/ src/config/config.test.ts src/tools/shell.test.ts src/scheduler/scheduler.test.ts src/utils/shell-utils.test.ts
    • Observed: 17 policy test files (537 tests) passed; 5 targeted core test files (716 passed, 3 skipped) passed; @google/gemini-cli-core build succeeded.
  2. Run full repository lint (lint:all), strict ESLint on modified files, and full monorepo typecheck:
    npm run lint:all
    npm run typecheck
    • Observed: lint:all passed (exit 0); 0 typecheck errors across all workspaces.
  3. Edge cases covered by unit tests:
    • Interactive and headless (nonInteractive) active trusted YOLO runs for build-file edits and tainted shell commands
    • Untrusted workspace (isTrustedFolder() === false) still enforcing checks in YOLO mode
    • Admin-disabled YOLO (disableYoloMode / isYoloModeDisabled() === true) still enforcing checks across PolicyEngine, Scheduler, and ShellToolInvocation
    • Higher-tier explicit user/admin ASK_USER / DENY rules and forcedDecision: 'ask_user' hooks still enforced in YOLO mode

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed — existing docs do not document build-file/taint overrides and already describe YOLO as auto-approving tools per yolo.toml)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any — none)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@zhoulujue
zhoulujue requested review from a team as code owners November 30, 2026 05:16
@github-actions github-actions Bot added the size/l A large sized PR label Nov 30, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/L

  • Lines changed: 475
  • Additions: +430
  • Deletions: -45
  • Files changed: 9

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the behavior of the 'YOLO' approval mode by allowing it to respect trusted environments while maintaining strict security boundaries. By enabling the system to bypass certain hardcoded prompts for build file edits and shell taint risks when in a trusted, active YOLO state, it improves the developer experience for autonomous workflows. The changes ensure that these overrides are safely gated by folder trust checks and administrative settings, preserving existing security invariants for untrusted or restricted contexts.

Highlights

  • YOLO Mode Integration: Enabled trusted YOLO mode to bypass hardcoded confirmation prompts for build file modifications and shell taint risks, provided the folder is trusted and YOLO mode is not administratively disabled.
  • Policy Engine Updates: Introduced isYoloModeDisabled to the PolicyEngine configuration to allow for granular control over YOLO mode safety overrides.
  • Shell Tool Enhancements: Updated ShellToolInvocation to delegate command substitution checks to the PolicyEngine when in active YOLO mode, preventing unnecessary blocking.
  • Security Invariants: Ensured that all security protections remain active in untrusted folders, when YOLO mode is disabled, or when explicit higher-tier policy rules/hooks require user intervention.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🛑 Action Required: Evaluation Approval

Steering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged.

Maintainers:

  1. Go to the Workflow Run Summary.
  2. Click the yellow 'Review deployments' button.
  3. Select the 'eval-gate' environment and click 'Approve'.

Once approved, the evaluation results will be posted here automatically.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates the disableYoloMode configuration into the PolicyEngine and Scheduler via a new isYoloModeDisabled callback. It refactors the 'Build File Protection' and shell tool execution logic to bypass user confirmation prompts for build file modifications, untrusted flags, and taint risks only when an active, trusted YOLO mode is enabled (i.e., approval mode is YOLO, the folder is trusted, and YOLO mode is not disabled). Comprehensive unit tests have been added across the configuration, policy engine, scheduler, and shell tool modules to validate these behaviors under various combinations of trust and YOLO mode states. There are no review comments, so I have no feedback to provide.

Note: Security Review did not run due to the size of the PR.

@zhoulujue

Copy link
Copy Markdown
Author

Hi @DavidAPierce @spencer426 — reopening this cleanly as #30552 because #30268 hit the 14-day help wanted auto-close bot over the Thanksgiving weekend while waiting for review.

The branch is rebased on latest main (60f8082) with cla/google, E2E (Chained), and gemini-code-assist (0 issues) all green.

To unblock review and prevent another 14-day auto-close, could you let me know:

  1. If bypassing hardcoded taint/build-file escalations in active, trusted YOLO mode (ApprovalMode.YOLO && isTrustedFolder && !isYoloModeDisabled, preserving higher-tier user/admin rules, hooks, safety checkers, and non-YOLO/untrusted protections) matches the intended direction — and if so, add help wanted + approve eval-gate; or
  2. If you'd prefer keeping these prompts on by default in YOLO and gating the bypass behind an explicit opt-in security.* setting — happy to adapt the PR immediately.

Thanks!

@zhoulujue
zhoulujue force-pushed the fix/yolo-taint-and-build-file-prompts branch from 574de2a to 384a440 Compare December 2, 2026 03:06
@zhoulujue

Copy link
Copy Markdown
Author

Rebased onto latest main (e98c23e → 384a440) and re-verified locally (21 policy/core test files, 1,085 passed; npm run lint:all exit 0; monorepo npm run typecheck 0 errors). area/security is now synced on this PR as well.

@DavidAPierce @spencer426 @abhipatel12 @adamfweidman — since gemini-scheduled-issue-triage has been failing on #30004/#29682, could one of you help unblock review when you have a moment?

  • If bypassing hardcoded taint/build-file escalations in active, trusted YOLO (ApprovalMode.YOLO && isTrustedFolder && !isYoloModeDisabled) matches the intended direction, clicking "Approve and run" on CI + approving eval-gate (and adding help wanted if appropriate) is all that's needed to run the full remote checks.
  • If you'd prefer keeping external taint checks enabled by default in YOLO, just let me know in one line and I will immediately adapt this PR to either (a) an explicit opt-in security.* setting, or (b) targeted fixes for #30004's remaining false positives (~/.gemini/tmp, workspace .sh, ~/) in untrustedContextTracker.ts.

Thanks!

This branch is waiting to be deployed

1 waiting deployment
eval-gate — 384a440d Waiting Dec 2, 2026 by zhoulujue via Evaluate Steering & Regressions #2408
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/security Issues related to security size/l A large sized PR

Projects

None yet

1 participant