fix(plan): sandbox path resolution in Plan Mode to prevent hallucinations#22737
fix(plan): sandbox path resolution in Plan Mode to prevent hallucinations#22737
Conversation
…ions and traversal
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 significantly enhances the security and reliability of file operations within the application's Plan Mode. By implementing strict sandboxing for path resolution, it ensures that all interactions with the file system are confined to a designated directory, effectively preventing potential directory traversal attacks and improving the accuracy of LLM-generated file paths. The changes streamline path handling and reinforce the integrity of the planning process. Highlights
Changelog
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. 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a critical security fix to prevent directory traversal vulnerabilities in Plan Mode. By renaming plan_path to plan_filename and consistently using path.basename to sanitize file paths provided by the LLM, the changes effectively sandbox file operations to the designated plansDir. The removal of targetDir from validatePlanPath and the addition of the isPlanMode check in file-writing tools are well-implemented and align with the goal of hardening the CLI against path-based attacks. I have one suggestion to improve consistency in path resolution.
Note: Security Review did not run due to the size of the PR.
|
Size Change: +604 B (0%) Total Size: 26.1 MB
ℹ️ View Unchanged
|
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
Currently running evals with bench-hub to see if exit plan mode calls fail |
🧠 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. |
|
/patch stable |
|
🚀 [Step 1/4] Patch workflow(s) waiting for approval! 📋 Details:
⏳ Status: The patch creation workflow has been triggered and is waiting for deployment approval. Please visit the specific workflow links below and approve the runs. 🔗 Track Progress: |
…ions (#22737) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ions (google-gemini#22737) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ions (google-gemini#22737) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary
Fixes LLM path hallucinations during Plan Mode by sandboxing path resolution directly to the active session's designated
plansDir.Details
plan_pathtoplan_filenamein theexit_plan_modetool schema and internal interfaces to instruct the LLM against producing absolute paths.exit_plan_mode,write_file, andedit(replace) tools so that whenisPlanMode()is true, they automatically extract thepath.basenamefrom the LLM's input and attach it safely to theplansDir.targetDirresolution logic fromvalidatePlanPathas paths are now inherently restricted toplansDir.Related Issues
Fixes #22307
Fixes #20549
Fixes #21359
Fixes #22933
How to Validate
Plan mode should always successfully write in the plans directory
Pre-Merge Checklist