Skip to content

fix(cli): prevent @path expansion in pasted text by default - #29458

Closed
MartinCajiao wants to merge 6 commits into
google-gemini:mainfrom
MartinCajiao:codex/gemini-cli-paste-at-expansion-security
Closed

MartinCajiao wants to merge 6 commits into
google-gemini:mainfrom
MartinCajiao:codex/gemini-cli-paste-at-expansion-security

Conversation

@MartinCajiao

@MartinCajiao MartinCajiao commented Sep 23, 2026 •

Copy link
Copy Markdown

Summary

Pasting shell text such as user@host:~/project$ cat @id_rsa can trigger @path expansion and upload a file the user only meant to paste. This changes ui.escapePastedAtSymbols to default to true, with regression coverage for clipboard and bracketed terminal paste. Typing @path manually still includes a file.

Scope

This is a partial mitigation for #26730: it addresses the request to disable expansion in pasted text by default. It does not add confirmation before uploading sensitive files or heuristics for common shell prompts; those remain outside this change.

Related Issue

Related to #26730

How to Validate

  • npx vitest run src/config/settingsSchema.test.ts src/ui/components/InputPrompt.test.tsx -t "escape @ symbols" --maxWorkers=1 (3 passed)
  • Prettier and ESLint checks for the changed files passed.
  • npm run docs:settings --ignore-scripts generated the updated docs and schema successfully.

@MartinCajiao
MartinCajiao requested review from a team as code owners September 23, 2026 03:37
@github-actions github-actions Bot added the size/m A medium sized PR label Sep 23, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/M

  • Lines changed: 54
  • Additions: +43
  • Deletions: -11
  • Files changed: 6

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 improves the safety of the CLI by changing the default behavior for handling pasted text. By enabling @ symbol escaping by default, users can paste shell commands containing @ characters without inadvertently triggering file path expansion. The change includes necessary updates to configuration schemas and documentation, alongside robust testing to verify the fix across different paste methods.

Highlights

  • Default behavior change: Updated the ui.escapePastedAtSymbols setting to default to true, preventing accidental @path expansion when pasting shell commands.
  • Regression testing: Added comprehensive test coverage for both standard clipboard pasting and bracketed terminal paste scenarios to ensure @ symbols are correctly escaped.
  • Documentation updates: Updated the CLI settings documentation and schema to reflect the new default behavior and clarify that manual @path usage remains supported.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 updates the default value of the ui.escapePastedAtSymbols setting from false to true, ensuring that @ symbols in pasted text are escaped by default to prevent unintended @path expansion. The documentation, settings schema, and test suites have been updated to align with this new default behavior. There are no review comments to address, and I have no additional feedback to provide.

@gemini-cli gemini-cli Bot added priority/p1 Important and should be addressed in the near term. area/security Issues related to security labels Sep 23, 2026
@gemini-cli

gemini-cli Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'.

This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

@gemini-cli

gemini-cli Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/security Issues related to security priority/p1 Important and should be addressed in the near term. size/m A medium sized PR status/pr-nudge-sent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant