fix(patch): cherry-pick 4e5dfd0 to release/v0.35.0-preview.1-pr-23074 to patch version v0.35.0-preview.1 and create version 0.35.0-preview.2#23134
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 refines the memory discovery mechanism within the core package to improve how relevant memory files are identified. It extends the upward traversal logic to correctly reach the Git repository root, accommodating various project structures including Git submodules and worktrees where the 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
|
There was a problem hiding this comment.
Code Review
The pull request modifies the memory discovery logic to traverse upward from a trusted root to the git repository root (if one exists) when searching for GEMINI.md files, instead of stopping at the trusted root. This change allows for better context discovery in git repositories, including those using submodules or worktrees where .git is a file. However, a security vulnerability was introduced in loadJitSubdirectoryMemory where this upward traversal to an untrusted git root from a trusted root could lead to prompt injection by loading malicious GEMINI.md files if an attacker controls a parent directory that is a git root.
| const gitRoot = await findProjectRoot(bestRoot); | ||
| const resolvedCeiling = gitRoot ? normalizePath(gitRoot) : bestRoot; |
There was a problem hiding this comment.
Similar to the issue in getEnvironmentMemoryPaths, the introduction of gitRoot and resolvedCeiling in loadJitSubdirectoryMemory for JIT memory loading, while aiming for consistent behavior, creates a security vulnerability. This allows the function to traverse upward to an untrusted git root from a trusted root, potentially loading malicious GEMINI.md files and enabling prompt injection if an attacker controls a parent directory that is a git root.
// Find the git root to use as the traversal ceiling.
// If no git root exists, fall back to the trusted root as the ceiling.
const gitRoot = await findProjectRoot(bestRoot);
const resolvedCeiling = gitRoot ? normalizePath(gitRoot) : bestRoot;|
Size Change: +340 B (0%) Total Size: 26.2 MB
ℹ️ View Unchanged
|
dd95008
into
release/v0.35.0-preview.1-pr-23074
This PR automatically cherry-picks commit 4e5dfd0 to patch version v0.35.0-preview.1 in the preview release to create version 0.35.0-preview.2.