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
Conversation
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
|
Size Change: +2.26 kB (+0.01%) Total Size: 34.1 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
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.
| 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; | ||
| } |
There was a problem hiding this comment.
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
- 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.
- 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.
| 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; | ||
| } |
There was a problem hiding this comment.
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
- 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.
- 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.
8d4bd62
into
release/v0.39.0-preview.0-pr-25138
|
✅ 62 tests passed successfully on gemini-3-flash-preview. 🧠 Model Steering GuidanceThis PR modifies files that affect the model's behavior (prompts, tools, or instructions).
This is an automated guidance message triggered by steering logic signatures. |
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.