Skip to content

fix(patch): cherry-pick a4e98c0 to release/v0.39.0-preview.0-pr-25138 to patch version v0.39.0-preview.0 and create version 0.39.0-preview.1#25766

Merged
SandyTao520 merged 1 commit intorelease/v0.39.0-preview.0-pr-25138from
hotfix/v0.39.0-preview.0/0.39.0-preview.1/preview/cherry-pick-a4e98c0/pr-25138
Apr 21, 2026
Merged

fix(patch): cherry-pick a4e98c0 to release/v0.39.0-preview.0-pr-25138 to patch version v0.39.0-preview.0 and create version 0.39.0-preview.1#25766
SandyTao520 merged 1 commit intorelease/v0.39.0-preview.0-pr-25138from
hotfix/v0.39.0-preview.0/0.39.0-preview.1/preview/cherry-pick-a4e98c0/pr-25138

Conversation

@gemini-cli-robot
Copy link
Copy Markdown
Collaborator

This PR automatically cherry-picks commit a4e98c0 to patch version v0.39.0-preview.0 in the preview release to create version 0.39.0-preview.1.

@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 enhances the Gemini CLI's Plan Mode by enabling support for nested directory structures when creating and managing implementation plans. It introduces a centralized, secure path resolution mechanism that validates file paths against the designated plans directory, effectively preventing unauthorized access or path traversal. These changes ensure that the model can organize plans in subdirectories while maintaining strict security boundaries.

Highlights

  • Plan Path Resolution: Implemented robust path resolution and validation for plan files, allowing for nested directory structures within the plans directory while preventing path traversal attacks.
  • Tool Integration: Updated EditTool, WriteFileTool, and ExitPlanModeTool to utilize the new resolveAndValidatePlanPath utility, ensuring consistent and secure path handling across all plan-related operations.
  • Prompt Updates: Updated system prompts to correctly reflect the relative pathing for plan files, improving the model's ability to navigate and manage plans.
  • Testing: Added comprehensive test cases to verify nested path handling and path traversal protection, ensuring the reliability of the new path resolution logic.
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.

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
Copy link
Copy Markdown

Size Change: +2.26 kB (+0.01%)

Total Size: 34.1 MB

Filename Size Change
./bundle/chunk-ANNHIQR4.js 0 B -3.55 MB (removed) 🏆
./bundle/chunk-KGCSLADU.js 0 B -14.9 MB (removed) 🏆
./bundle/chunk-ZANKCIQ4.js 0 B -3.8 kB (removed) 🏆
./bundle/core-4VY7J3GV.js 0 B -46.5 kB (removed) 🏆
./bundle/devtoolsService-SQI6P33A.js 0 B -28.4 kB (removed) 🏆
./bundle/gemini-XZOI4GHF.js 0 B -553 kB (removed) 🏆
./bundle/interactiveCli-SNW67VFT.js 0 B -1.29 MB (removed) 🏆
./bundle/oauth2-provider-R2DW6JYQ.js 0 B -9.16 kB (removed) 🏆
./bundle/chunk-GB7WKWWK.js 3.55 MB +3.55 MB (new file) 🆕
./bundle/chunk-KAPPUY2U.js 3.8 kB +3.8 kB (new file) 🆕
./bundle/chunk-ZJKLFYO6.js 14.9 MB +14.9 MB (new file) 🆕
./bundle/core-SI47B3QH.js 46.6 kB +46.6 kB (new file) 🆕
./bundle/devtoolsService-U7E7US3S.js 28.4 kB +28.4 kB (new file) 🆕
./bundle/gemini-RZQPRTE4.js 553 kB +553 kB (new file) 🆕
./bundle/interactiveCli-73QQ4SXZ.js 1.29 MB +1.29 MB (new file) 🆕
./bundle/oauth2-provider-YOKWQGPD.js 9.16 kB +9.16 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
./bundle/bundled/third_party/index.js 8 MB 0 B
./bundle/chunk-34MYV7JD.js 2.45 kB 0 B
./bundle/chunk-5AUYMPVF.js 858 B 0 B
./bundle/chunk-5PS3AYFU.js 1.18 kB 0 B
./bundle/chunk-664ZODQF.js 124 kB 0 B
./bundle/chunk-DAHVX5MI.js 206 kB 0 B
./bundle/chunk-IUUIT4SU.js 56.5 kB 0 B
./bundle/chunk-QM5IP3NK.js 1.97 MB 0 B
./bundle/chunk-RJTRUG2J.js 39.8 kB 0 B
./bundle/cleanup-OQUFKYCG.js 0 B -932 B (removed) 🏆
./bundle/devtools-36NN55EP.js 696 kB 0 B
./bundle/dist-T73EYRDX.js 356 B 0 B
./bundle/events-XB7DADIJ.js 418 B 0 B
./bundle/gemini.js 4.97 kB 0 B
./bundle/getMachineId-bsd-TXG52NKR.js 1.55 kB 0 B
./bundle/getMachineId-darwin-7OE4DDZ6.js 1.55 kB 0 B
./bundle/getMachineId-linux-SHIFKOOX.js 1.34 kB 0 B
./bundle/getMachineId-unsupported-5U5DOEYY.js 1.06 kB 0 B
./bundle/getMachineId-win-6KLLGOI4.js 1.72 kB 0 B
./bundle/memoryDiscovery-MYQ3ZWKM.js 980 B 0 B
./bundle/multipart-parser-KPBZEGQU.js 11.7 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 222 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 229 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 13.4 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 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-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B
./bundle/src-QVCVGIUX.js 47 kB 0 B
./bundle/tree-sitter-7U6MW5PS.js 274 kB 0 B
./bundle/tree-sitter-bash-34ZGLXVX.js 1.84 MB 0 B
./bundle/cleanup-57SPBIBU.js 932 B +932 B (new file) 🆕

compressed-size-action

Copy link
Copy Markdown
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 enhances 'Plan Mode' by supporting nested directories for plans and transitioning from absolute to relative paths in system prompts. It introduces a centralized resolveAndValidatePlanPath utility to ensure file operations remain within the authorized plans directory. However, a security vulnerability was identified in the EditTool and WriteFileTool implementations: when path resolution fails, the code falls back to the raw input path, which could bypass 'Plan Mode' access controls. These fallbacks should be removed to ensure all paths are strictly validated.

Comment on lines 468 to +483
if (this.config.isPlanMode()) {
const safeFilename = path.basename(this.params.file_path);
this.resolvedPath = path.join(
this.config.storage.getPlansDir(),
safeFilename,
);
try {
this.resolvedPath = resolveAndValidatePlanPath(
this.params.file_path,
this.config.storage.getPlansDir(),
this.config.getProjectRoot(),
);
} catch (e) {
debugLogger.error(
'Failed to resolve plan path during EditTool invocation setup',
e,
);
// Validation fails, set resolvedPath to something that will fail validation downstream or just the raw path.
// It's safer to store it so validation in execute() or getConfirmationDetails() catches it.
this.resolvedPath = this.params.file_path;
}
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.

security-high high

This implementation introduces a Broken Access Control vulnerability by falling back to the raw file_path when resolveAndValidatePlanPath fails, which bypasses 'Plan Mode' restrictions. To ensure consistent path resolution, use a robust function like resolveToRealPath for all validations. Additionally, as a utility performing file system operations, this tool should validate path inputs internally to prevent traversal vulnerabilities. Please remove the fallback and ensure this.resolvedPath is always absolute and validated against the project root.

References
  1. Ensure consistent path resolution by using a single, robust function (e.g., resolveToRealPath) for all related path validations, including internal validations in components like WorkspaceContext.
  2. Utility functions that perform file system operations should validate their path inputs internally to prevent path traversal vulnerabilities, rather than relying solely on callers to perform validation.

Comment on lines 171 to +185
if (this.config.isPlanMode()) {
const safeFilename = path.basename(this.params.file_path);
this.resolvedPath = path.join(
this.config.storage.getPlansDir(),
safeFilename,
);
try {
this.resolvedPath = resolveAndValidatePlanPath(
this.params.file_path,
this.config.storage.getPlansDir(),
this.config.getProjectRoot(),
);
} catch (e) {
debugLogger.error(
'Failed to resolve plan path during WriteFileTool invocation setup',
e,
);
// Validation fails, set resolvedPath to something that will fail validation downstream or just the raw path.
this.resolvedPath = this.params.file_path;
}
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.

security-high high

This implementation introduces a Broken Access Control vulnerability by falling back to the raw file_path when resolveAndValidatePlanPath fails, which bypasses 'Plan Mode' restrictions. To ensure consistent path resolution, use a robust function like resolveToRealPath for all validations. Additionally, as a utility performing file system operations, this tool should validate path inputs internally to prevent traversal vulnerabilities. Please remove the fallback and ensure this.resolvedPath is always absolute and validated against the project root.

References
  1. Ensure consistent path resolution by using a single, robust function (e.g., resolveToRealPath) for all related path validations, including internal validations in components like WorkspaceContext.
  2. Utility functions that perform file system operations should validate their path inputs internally to prevent path traversal vulnerabilities, rather than relying solely on callers to perform validation.

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Apr 21, 2026
@SandyTao520 SandyTao520 merged commit 8d4bd62 into release/v0.39.0-preview.0-pr-25138 Apr 21, 2026
30 checks passed
@SandyTao520 SandyTao520 deleted the hotfix/v0.39.0-preview.0/0.39.0-preview.1/preview/cherry-pick-a4e98c0/pr-25138 branch April 21, 2026 22:04
@github-actions
Copy link
Copy Markdown

62 tests passed successfully on gemini-3-flash-preview.

🧠 Model Steering Guidance

This PR modifies files that affect the model's behavior (prompts, tools, or instructions).

  • 🚀 Maintainer Reminder: Please ensure that these changes do not regress results on benchmark evals before merging.

This is an automated guidance message triggered by steering logic signatures.

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.

3 participants