fix(patch): cherry-pick 4d4e16c to release/v0.27.0-preview.0-pr-17785 to patch version v0.27.0-preview.0 and create version 0.27.0-preview.1#17823
Conversation
Summary of ChangesHello @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 is an automated cherry-pick operation to patch a specific release. The core change involves making 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. 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
|
|
Size Change: +38 B (0%) Total Size: 23.5 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request refactors the updateSetting function to require a workspaceDir, improving the robustness of extension setting configuration. However, this change introduces a critical vulnerability: malicious extensions can inject arbitrary environment variables into the workspace's .env file, which are then loaded into the CLI's process environment, potentially leading to Remote Code Execution. Additionally, a minor issue was identified in extension-manager-hydration.test.ts regarding the use of process.cwd() instead of a test-specific temporary directory, which could make the test brittle.
| requestSetting: (setting: ExtensionSetting) => Promise<string>, | ||
| scope: ExtensionSettingScope, | ||
| workspaceDir?: string, | ||
| workspaceDir: string, |
There was a problem hiding this comment.
The updateSetting function is vulnerable to environment variable injection. It does not properly escape newline characters in values or validate environment variable names (envVar) defined by extensions. By making workspaceDir mandatory and enabling the workspace scope, this PR exposes the ability for a malicious extension to inject arbitrary environment variables (e.g., NODE_OPTIONS, GEMINI_CLI_SYSTEM_SETTINGS_PATH) into the workspace's .env file. These variables are automatically loaded into the process environment via loadEnvironment, which can lead to Remote Code Execution (RCE). To remediate this, ensure that envVar names are validated against a whitelist and that values are properly escaped to prevent newline injection.
| 'MY_VALUE', | ||
| mockRequestSetting, | ||
| ExtensionSettingScope.USER, | ||
| process.cwd(), |
There was a problem hiding this comment.
For test isolation and correctness, it's better to use the tempDir created for this test suite instead of process.cwd(). The rest of the test setup uses tempDir as the workspace directory. Using process.cwd() could lead to unexpected behavior or test failures if the scope were changed to WORKSPACE, as it would reference a different directory than the one prepared for the test.
| process.cwd(), | |
| tempDir, |
9954615
into
release/v0.27.0-preview.0-pr-17785
This PR automatically cherry-picks commit 4d4e16c to patch version v0.27.0-preview.0 in the preview release to create version 0.27.0-preview.1.