-
Notifications
You must be signed in to change notification settings - Fork 14.5k
feat(core): add allowCommandSubstitution toggle in settings #27400
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,6 +183,17 @@ const SETTINGS_SCHEMA = { | |
| 'Additional admin policy files or directories to load.', | ||
| ), | ||
|
|
||
| allowCommandSubstitution: { | ||
| type: 'boolean', | ||
| label: 'Allow Command Substitution', | ||
| category: 'Security', | ||
| requiresRestart: true, | ||
| default: false, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the default The linked issue's #1 problem is "the model has no way to know in advance the command will be blocked," and it explicitly asks that YOLO mode default to |
||
| description: | ||
| 'Allow command substitution (e.g., $()) in shell tool execution.', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The description doesn't convey what enabling this actually does. It disables a command-injection protection — including for commands that were allowlisted or "always allowed" — which is exactly what the block's own llmContent describes as a security risk. Since this is the text users see in the settings dialog before flipping a security control, it should state the risk explicitly, e.g. "Allow command substitution ($(), backticks, <()) in shell commands. Warning: this disables a command-injection safeguard and lets substitution run inside otherwise-approved commands." |
||
| showInDialog: true, | ||
| }, | ||
|
Comment on lines
+186
to
+195
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
| general: { | ||
| type: 'object', | ||
| label: 'General', | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -464,7 +464,15 @@ export class ShellToolInvocation extends BaseToolInvocation< | |||||||||||
| } = options; | ||||||||||||
| const strippedCommand = stripShellWrapper(this.params.command); | ||||||||||||
|
|
||||||||||||
| if (detectCommandSubstitution(strippedCommand)) { | ||||||||||||
| const allowCommandSubstitution = | ||||||||||||
| typeof this.context.config.getAllowCommandSubstitution === 'function' | ||||||||||||
| ? this.context.config.getAllowCommandSubstitution() | ||||||||||||
| : false; | ||||||||||||
|
Comment on lines
+467
to
+470
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of
Suggested change
References
|
||||||||||||
|
|
||||||||||||
| if ( | ||||||||||||
| !allowCommandSubstitution && | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Building on the bot's security-high note on |
||||||||||||
| detectCommandSubstitution(strippedCommand) | ||||||||||||
| ) { | ||||||||||||
| return { | ||||||||||||
| llmContent: | ||||||||||||
| 'Command injection detected: command substitution syntax ' + | ||||||||||||
|
|
||||||||||||
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
allowCommandSubstitutionsetting is honored from the workspace configuration without verifying if the workspace is trusted. A malicious repository could enable this setting via a local configuration file (e.g.,.gemini/settings.json), bypassing security checks inShellTooland enabling command injection. This setting should be protected by atrustedFoldercheck, similar toapprovalModeandextensionRegistryURI. Additionally, ensureallowCommandSubstitutionis accessed from thesecurityobject in the settings schema to maintain consistency between the schema and TypeScript interfaces.References