mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 21:32:56 -07:00
Fix/command injection shell (#24170)
Co-authored-by: David Pierce <davidapierce@google.com>
This commit is contained in:
committed by
GitHub
parent
1c43deee07
commit
2a52611e71
@@ -40,6 +40,7 @@ import {
|
||||
stripShellWrapper,
|
||||
parseCommandDetails,
|
||||
hasRedirection,
|
||||
detectCommandSubstitution,
|
||||
normalizeCommand,
|
||||
escapeShellArg,
|
||||
} from '../utils/shell-utils.js';
|
||||
@@ -443,6 +444,18 @@ export class ShellToolInvocation extends BaseToolInvocation<
|
||||
} = options;
|
||||
const strippedCommand = stripShellWrapper(this.params.command);
|
||||
|
||||
if (detectCommandSubstitution(strippedCommand)) {
|
||||
return {
|
||||
llmContent:
|
||||
'Command injection detected: command substitution syntax ' +
|
||||
'($(), backticks, <() or >()) found in command arguments. ' +
|
||||
'On PowerShell, @() array subexpressions and $() subexpressions are also blocked. ' +
|
||||
'This is a security risk and the command was blocked.',
|
||||
returnDisplay:
|
||||
'Blocked: command substitution detected in shell command.',
|
||||
};
|
||||
}
|
||||
|
||||
if (signal.aborted) {
|
||||
return {
|
||||
llmContent: 'Command was cancelled by user before it could start.',
|
||||
|
||||
Reference in New Issue
Block a user