Skip to content

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

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

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

Conversation

@zhoulujue

@zhoulujue zhoulujue commented Nov 13, 2026 •

Copy link
Copy Markdown

Summary

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.

All indirect prompt-injection protections remain fully enforced in default and auto_edit 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

(Open to gating this behind an explicit security.* setting if maintainers prefer opt-in over default behavior in trusted YOLO mode.)

Related Issues

Fixes #30004
Related: #29682, #29680, #29687

How to Validate

  • Targeted unit tests (policy-engine.test.ts, config.test.ts, shell.test.ts, scheduler.test.ts):
    npm test -w @google/gemini-cli-core -- src/policy/policy-engine.test.ts src/config/config.test.ts src/tools/shell.test.ts src/scheduler/scheduler.test.ts
    Result: 4 test files passed, 583 tests passed.
  • CLI config/settings/confirmation tests (config.test.ts, settings.test.ts, ToolConfirmationMessage.test.tsx): 3 test files passed, 424 tests passed.
  • A2A server tests (@google/gemini-cli-a2a-server): 17 test files passed, 329 tests passed.
  • Workspace build (npm run build --workspaces), full monorepo typecheck (npm run typecheck), and strict ESLint (--max-warnings 0) on all modified files: all passed with 0 errors/warnings.

Pre-Merge Checklist

  • Rebased cleanly onto latest main (08e9a20) with no merge conflicts
  • Unit tests added/updated for active YOLO, headless YOLO, untrusted folders, disableYoloMode, higher-tier policy rules, and forcedDecision: 'ask_user'
  • Build, typecheck, ESLint (--max-warnings 0), and tests pass locally
  • CLA signed (cla/google passing)

@zhoulujue
zhoulujue requested review from a team as code owners November 13, 2026 06:33
@github-actions github-actions Bot added the size/l A large sized PR label Nov 13, 2026
@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 enables autonomous operation for trusted YOLO mode by relaxing confirmation requirements for build file modifications and command taint risks. It ensures that while users can run headless or interactive YOLO sessions without interruption, security protections remain fully enforced in untrusted environments, non-YOLO modes, or when explicitly restricted by policy.

Highlights

  • YOLO Mode Enforcement: Updated ShellToolInvocation, Scheduler, and PolicyEngine to respect active, trusted YOLO mode, allowing autonomous operations without confirmation prompts for build file modifications or tainted commands.
  • PolicyEngine Protection: Modified PolicyEngine to skip hardcoded build file protection downgrades only when in trusted YOLO mode, ensuring safety in untrusted workspaces or non-YOLO modes.
  • Scheduler Logic: Updated the scheduler to prevent escalation of ALLOW decisions to ASK_USER or DENY for tainted risks when YOLO mode is active.
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 13, 2026 •

Copy link
Copy Markdown

📊 PR Size: size/L

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

@google-cla

google-cla Bot commented Nov 13, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions

github-actions Bot commented Nov 13, 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 updates the policy engine, scheduler, and shell tool to bypass build file protection and taint risk confirmations when running in an active, trusted YOLO mode. Specifically, if YOLO mode is enabled and the folder is trusted, user confirmation is skipped for build file modifications and untrusted shell flags. However, these protections remain enforced if YOLO mode is disabled or if the folder is untrusted. Comprehensive unit tests have been added and updated across the policy engine, scheduler, and shell tool to validate these behaviors. No review comments were provided, so there is no additional feedback.

@zhoulujue

Copy link
Copy Markdown
Author

@googlebot I fixed it.

@zhoulujue
zhoulujue force-pushed the fix/yolo-taint-and-build-file-prompts branch from 312806a to 5683562 Compare November 13, 2026 06:48
@zhoulujue

Copy link
Copy Markdown
Author

Hi @DavidAPierce — gentle ping when you have a moment, since you reviewed #29250 and #29833.

This PR restores uninterrupted --approval-mode=yolo / -y execution (especially in headless -y -p runs where build-file edits and tainted flags currently fail hard with DENY), while keeping all indirect prompt-injection checks strictly enforced in default/auto_edit modes, untrusted workspaces (!isTrustedFolder()), isYoloModeDisabled(), and explicit user/admin policies.

Could you help approve the pending CI / eval-gate workflows, or let me know if you'd prefer a different approach (e.g., gating behind an explicit security.* setting)? Happy to adjust!

@gemini-cli

gemini-cli Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'.

This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

@zhoulujue

Copy link
Copy Markdown
Author

Hi @DavidAPierce @kschaab — quick follow-up ahead of the bot's 7-day auto-close (status/pr-nudge-sent).

This branch is freshly rebased onto main with no conflicts and addresses #29682 / #29680 / #30004 (uninterrupted trusted --yolo / -y runs, including headless -y -p).

Could you share a quick call on direction so I can get this merge-ready:

  1. Is bypassing taint/build-file prompts in active, trusted YOLO mode acceptable as implemented, or would you prefer gating it behind an explicit security.* setting / policy rule?
  2. If this is worth keeping open, could a maintainer add the help wanted label (to prevent auto-close) and approve the pending eval-gate workflow?

Happy to adjust quickly based on your feedback. Thanks!

@zhoulujue
zhoulujue force-pushed the fix/yolo-taint-and-build-file-prompts branch from 0d37deb to c691219 Compare November 25, 2026 04:34
@zhoulujue

Copy link
Copy Markdown
Author

/gemini review

@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 isYoloModeDisabled configuration and trusted folder checks into the PolicyEngine, Scheduler, and ShellTool to properly govern "YOLO" mode. Specifically, it ensures that build file protection, taint risk escalation, and untrusted flag confirmation checks are bypassed only when YOLO mode is active, the workspace folder is trusted, and YOLO mode is not explicitly 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. I have no additional feedback to provide as the implementation is clean and well-tested.

@gemini-cli gemini-cli Bot added the area/security Issues related to security label Nov 25, 2026
@zhoulujue
zhoulujue force-pushed the fix/yolo-taint-and-build-file-prompts branch from c691219 to 574de2a Compare November 26, 2026 06:32
@zhoulujue

Copy link
Copy Markdown
Author

Rebased cleanly onto latest main (60f8082, including #30451's shell wrapper policy checks) and re-verified all 592 targeted core tests (policy-engine, shell-substitution, config, shell, scheduler), typecheck, and eslint --max-warnings 0 — plus /gemini review returned 0 issues.

@abhipatel12 @spencer426 — flagging you here since you just reviewed/merged #30451 on policy-engine.ts / shell.test.ts. The automated lifecycle bot will close this PR at 2026-11-28 01:30 UTC unless a maintainer adds help wanted (or 🔒 maintainer only).

Could one of you either add a label to keep this open past the holiday weekend, or drop a quick 1-line call on direction (trusted YOLO default vs. gating behind an explicit security.* setting, which I can push right away)? Thanks!

@gemini-cli

gemini-cli Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

This branch was successfully deployed

No deployments
eval-gate — 574de2af Deployed Nov 30, 2026 by zhoulujue via Evaluate Steering & Regressions #2399
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 status/pr-nudge-sent

Projects

None yet

1 participant