Skip to content

fix(patch): cherry-pick 08e8eea to release/v0.28.2-pr-18855 to patch version v0.28.2 and create version 0.28.3#18904

Closed
gemini-cli-robot wants to merge 1 commit intorelease/v0.28.2-pr-18855from
hotfix/v0.28.2/0.28.3/stable/cherry-pick-08e8eea/pr-18855
Closed

fix(patch): cherry-pick 08e8eea to release/v0.28.2-pr-18855 to patch version v0.28.2 and create version 0.28.3#18904
gemini-cli-robot wants to merge 1 commit intorelease/v0.28.2-pr-18855from
hotfix/v0.28.2/0.28.3/stable/cherry-pick-08e8eea/pr-18855

Conversation

@gemini-cli-robot
Copy link
Collaborator

This PR automatically cherry-picks commit 08e8eea to patch version v0.28.2 in the stable release to create version 0.28.3.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gemini-cli-robot, 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 detection and handling of headless environments across the CLI and core libraries. It ensures that operations requiring user interaction, such as folder trust prompts, are automatically approved when running in a headless context, improving automation and CI/CD compatibility. The changes also standardize how headless mode is determined by incorporating command-line arguments and query parameters into the detection logic.

Highlights

  • Enhanced Headless Mode Detection: The isHeadlessMode function now incorporates more robust logic, considering the query option and checking process.argv for common headless or auto-approve flags such as -p, --prompt, -y, and --yolo.
  • Integrated Headless Mode with Folder Trust: The isWorkspaceTrusted and isPathTrusted functions have been updated to accept headlessOptions, ensuring that folder trust is automatically granted when the application is operating in a headless environment.
  • Updated CLI Configuration Loading: The loadCliConfig function was modified to consistently pass prompt and query arguments to the isWorkspaceTrusted and isHeadlessMode calls, standardizing headless behavior across the CLI.
  • Improved Test Coverage: New test cases were added to verify the correct behavior of isPathTrusted in headless scenarios and to confirm that isHeadlessMode accurately identifies headless environments based on query parameters and process.argv flags.
Changelog
  • packages/cli/src/config/config.ts
    • Updated isWorkspaceTrusted call to include prompt and query from argv.
    • Modified isHeadlessMode call for interactive flag to pass both prompt and query.
  • packages/cli/src/config/trustedFolders.test.ts
    • Added a test case to confirm isPathTrusted returns true when isHeadlessMode is active.
  • packages/cli/src/config/trustedFolders.ts
    • Imported HeadlessModeOptions type.
    • Modified isPathTrusted to return true immediately if isHeadlessMode is detected via headlessOptions.
    • Updated getWorkspaceTrustFromLocalConfig and isWorkspaceTrusted to accept and pass headlessOptions.
  • packages/core/src/utils/headless.test.ts
    • Added tests to verify isHeadlessMode returns true when query is provided or when -p, --prompt, -y, or --yolo flags are present in process.argv.
    • Refactored process.stdout and process.stdin mocking to use Object.defineProperty for better test isolation.
  • packages/core/src/utils/headless.ts
    • Refactored isHeadlessMode logic to prioritize CI environment detection, then TTY status, then explicit options.prompt or options.query, and finally a fallback check for specific flags in process.argv.
Activity
  • This pull request was automatically created to cherry-pick commit 08e8eea to patch version v0.28.2 and create version 0.28.3.
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link
Contributor

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

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 intends to improve headless mode detection and ensure folder trust checks are bypassed in non-interactive scenarios by considering query arguments and process.argv. However, it introduces a critical security vulnerability: broadening the definition of headless mode to include flags like --yolo and positional queries conflates it with folder trust, allowing an attacker to bypass the Folder Trust mechanism. This could lead to Remote Code Execution (RCE) by loading malicious .gemini/settings.json files if a user is tricked into running a command in a malicious directory. Furthermore, the process.argv check might not correctly handle arguments using an equals sign.

Comment on lines +43 to 51
if (isNotTTY || !!options?.prompt || !!options?.query) {
return true;
}

// Fallback: check process.argv for flags that imply headless or auto-approve mode.
return process.argv.some(
(arg) =>
arg === '-p' || arg === '--prompt' || arg === '-y' || arg === '--yolo',
);
Copy link
Contributor

Choose a reason for hiding this comment

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

security-critical critical

This section introduces a critical security vulnerability. Expanding isHeadlessMode to return true for -y/--yolo flags or a query directly impacts isWorkspaceTrusted, allowing an attacker to bypass the Folder Trust security mechanism. This could lead to Remote Code Execution (RCE) if a user is tricked into running gemini with these flags or a query in a malicious directory, enabling the loading of untrusted local configurations (.gemini/settings.json) and environment variables (.env). Furthermore, the current argument parsing for flags like --prompt and --yolo is not robust; it fails for arguments using an equals sign (e.g., --prompt=my-prompt), which could have unintended security consequences or functional issues in headless mode detection.

Comment on lines +133 to +135
if (isHeadlessMode(headlessOptions)) {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

security-critical critical

Automatically granting folder trust based on isHeadlessMode is insecure, especially with the changes in this PR that allow isHeadlessMode to be triggered by common CLI flags like --yolo or even a simple positional query.

This creates a direct security bypass where untrusted workspaces are treated as trusted. When a workspace is trusted, the CLI loads local configuration files that can override sensitive settings. An attacker can place a malicious .gemini/settings.json in a folder and achieve Remote Code Execution (RCE) if a user runs the CLI in that folder with any argument that triggers the broadened isHeadlessMode check.

Comment on lines +369 to 371
if (isHeadlessMode(headlessOptions)) {
return { isTrusted: true, source: undefined };
}
Copy link
Contributor

Choose a reason for hiding this comment

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

security-critical critical

This check bypasses the folder trust mechanism if the environment is considered 'headless'. As noted in the review for headless.ts, the definition of headless mode has been dangerously expanded to include common interactive flags. This allows for a complete bypass of the security boundary intended to protect users from malicious local configurations.

@github-actions
Copy link

Size Change: +382 B (0%)

Total Size: 23.7 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 23.7 MB +382 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

@gemini-cli
Copy link
Contributor

gemini-cli bot commented Mar 15, 2026

Hi there! Thank you for your contribution to Gemini CLI. We really appreciate the time and effort you've put into this pull request.

To keep our backlog manageable and ensure we're focusing on current priorities, we are closing pull requests that haven't seen maintainer activity for 30 days. Currently, the team is prioritizing work associated with 🔒 maintainer only or help wanted issues.

If you believe this change is still critical, please feel free to comment with updated details. Otherwise, we encourage contributors to focus on open issues labeled as help wanted. Thank you for your understanding!

@gemini-cli gemini-cli bot closed this Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants