fix(security): enforce case-insensitive sensitive path blocklist and vscode hitl#27966
fix(security): enforce case-insensitive sensitive path blocklist and vscode hitl#27966luisfelipe-alt wants to merge 2 commits into
Conversation
|
📊 PR Size: size/M
|
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 introduces critical security enhancements to the Gemini CLI by hardening path validation logic. By enforcing case-insensitive checks on sensitive directory segments and requiring explicit user approval for modifications to IDE configuration files, the changes mitigate potential vulnerabilities related to path traversal and unauthorized configuration tampering in automated execution environments. 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 the 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 counterproductive. 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
This pull request implements case-insensitive blocklist checks for sensitive paths (like .git, .env, and node_modules) and requires user confirmation (ASK_USER) for .vscode configuration files. The review highlights critical security issues, including a sandbox bypass where .vscode paths outside the workspace incorrectly trigger ASK_USER instead of DENY, and a Windows trailing character bypass (e.g., .git or .vscode.). The feedback suggests validating workspace allowance before checking blocked segments, handling trailing spaces/dots, using a unified path resolution function (resolveToRealPath), and adding regression tests to verify these edge cases.
93adb5c to
a00ecfd
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces case-insensitive blocklist checks for sensitive paths (such as .git, .env, and node_modules) and requires explicit user confirmation for .vscode configuration files. It also adds comprehensive regression tests to verify these security controls. The review feedback highlights potential bypasses on Windows via NTFS Alternate Data Streams (e.g., .vscode::$DATA) and suggests stripping stream identifiers during segment cleaning, as well as using a unified path resolution function like resolveToRealPath to ensure consistent validation across components.
e4b65ea to
617d084
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements case-insensitive blocklist checks for sensitive paths (such as .git, .env, and node_modules) and requires explicit user confirmation (ASK_USER) for modifying .vscode configuration files within the workspace. The feedback suggests refactoring the path validation logic to use asynchronous file system operations instead of synchronous ones to avoid blocking the event loop, and ensuring consistent path resolution.
4a50962 to
e2f2eb2
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements a case-insensitive blocklist for sensitive paths (such as ".git", ".env", and "node_modules") and adds special handling for ".vscode" configuration files to prevent security bypasses, including Windows trailing characters and NTFS Alternate Data Streams. It also refactors safelyResolvePath to use asynchronous file system operations and adds comprehensive regression tests. There are no review comments, and I have no feedback to provide.
Summary
This PR implements a 100% robust, production-grade security fix for the case-insensitivity bypass and prompt injection vulnerability in Gemini CLI. It enforces a strict, case-insensitive blocklist for sensitive directories/files (
.git,.env,node_modules) and ensures that any modifications to.vscode/configuration files always require explicit user confirmation (Human-in-the-Loop), even in automated modes likeautoEditorYOLO.Details
WorkspaceContext: UpdatedisPathWithinWorkspaceinpackages/core/src/utils/workspaceContext.tsto split resolved paths into segments and check them case-insensitively against['.git', '.env', 'node_modules'].AllowedPathChecker: UpdatedAllowedPathCheckerinpackages/core/src/safety/built-in.tsto enforce the same case-insensitive segment blocklist check, returningSafetyCheckDecision.DENYif matched..vscode/Configuration Files: UpdatedAllowedPathCheckerto detect if a path is inside.vscode/(case-insensitively) and returnSafetyCheckDecision.ASK_USER, which downgrades the policy engine's decision toASK_USER(requiring explicit user confirmation) even in automated modes likeautoEditorYOLO.packages/core/src/utils/workspaceContext.test.tsandpackages/core/src/safety/built-in.test.tsto verify the fix.Related Issues
How to Validate
Pre-Merge Checklist