-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Warn user when we overwrite a command due to conflict with extensions #17249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @chrstnb, 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 usability of extension command management by addressing potential "alphabetical precedence hijacking" issues. It introduces proactive conflict detection during extension installation, warning users about command name clashes and requiring their consent before proceeding. Additionally, it provides clear notifications when extension commands are automatically prefixed to resolve conflicts, ensuring transparency and preventing unexpected behavior. 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: +2.97 kB (+0.01%) Total Size: 23.2 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request aims to mitigate extension command hijacking by checking for conflicts during installation and notifying users of renames. However, the new conflict detection logic in ExtensionManager is vulnerable to terminal injection because command names derived from extension filenames are used unsanitized in a security-sensitive consent prompt, which could allow manipulation of warning messages. Furthermore, the conflict detection logic has a high-severity issue that could lead to false positives by not fully validating .toml files against the schema.
| for (const file of files) { | ||
| const relativePath = file.substring(0, file.length - 5); // length of '.toml' | ||
| const baseCommandName = relativePath | ||
| .split(path.sep) | ||
| .map((segment) => segment.replaceAll(':', '_')) | ||
| .join(':'); | ||
|
|
||
| if (currentCommandNames.has(baseCommandName)) { | ||
| conflicts.push({ | ||
| commandName: baseCommandName, | ||
| renamedName: `${extensionName}.${baseCommandName}`, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| if (conflicts.length > 0) { | ||
| const conflictList = conflicts | ||
| .map( | ||
| (c) => | ||
| ` - '/${c.commandName}' (will be renamed to '/${c.renamedName}')`, | ||
| ) | ||
| .join('\n'); | ||
|
|
||
| const warning = `WARNING: Installing extension '${extensionName}' will cause the following command conflicts:\n${conflictList}\n\nDo you want to continue installation?`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checkCommandConflicts method is vulnerable to terminal injection as command names (baseCommandName) derived from filenames are not sanitized for ANSI escape sequences, potentially allowing malicious extensions to manipulate the terminal output during the consent warning. Sanitize these command names using escapeAnsiCtrlCodes. Furthermore, the current conflict detection logic can lead to false positives because it checks for .toml files without validating them against the TomlCommandDefSchema. Ensure accuracy by parsing and validating each .toml file against the schema before considering it a conflict.
|
Hi there! Thank you for your contribution to Gemini CLI. We really appreciate the time and effort you've put into this pull request. To keep our backlog manageable and ensure we're focusing on current priorities, we are closing pull requests that haven't seen maintainer activity for 30 days. Currently, the team is prioritizing work associated with 🔒 maintainer only or help wanted issues. If you believe this change is still critical, please feel free to comment with updated details. Otherwise, we encourage contributors to focus on open issues labeled as help wanted. Thank you for your understanding! |
Summary
PR Description: Extension Command Precedence Hijacking Mitigations
Description
This PR implements several security and usability mitigations to prevent "alphabetical precedence hijacking" of extension commands, as described in issue #1207.
Malicious extensions could previously capture unprefixed command names (e.g.,
/gcloud:deploy) simply by choosing a name that sorts alphabetically before legitimate extensions. These changes make command provenance explicit and warn users before potentially hijacked names are installed.Key Changes
1, Notification on Extension Command Prefixing
CommandService.tsto dispatch an 'info' feedback event when an extension command is automatically renamed (prefixed) due to a naming conflict.Extension command '/deploy' from 'firebase' was renamed to '/firebase.deploy' due to a conflict with an existing command.3. Extension Installation Conflict Check
checkCommandConflictstoExtensionManager.ts.commands/directory and compares proposed command names against all currently registered commands.Verification Results
Automated Tests
packages/cli/src/services/CommandService.test.tsto verify that conflict notifications are emitted.CommandServicetests pass.Test Command
npm test -w packages/cli -- src/services/CommandService.test.tsFixes #1207
Details
Related Issues
How to Validate
Pre-Merge Checklist