google-gemini/gemini-cli · error · Error
Security configuration not loaded. Cannot verify shell comma
Error message
Security configuration not loaded. Cannot verify shell command permissions for '${this.commandName}'. Aborting. What it means
Thrown by ShellProcessor.processString() when the prompt contains a shell injection trigger ('!{') but context.services.agentContext?.config is undefined. The processor refuses to run shell commands without the security/policy config because it must call config.getPolicyEngine().check() to authorize each command.
Source
Thrown at packages/cli/src/services/prompt-processors/shellProcessor.ts:79
this.processString(text, context),
);
}
private async processString(
prompt: string,
context: CommandContext,
): Promise<PromptPipelineContent> {
const userArgsRaw = context.invocation?.args || '';
if (!prompt.includes(SHELL_INJECTION_TRIGGER)) {
return [
{ text: prompt.replaceAll(SHORTHAND_ARGS_PLACEHOLDER, userArgsRaw) },
];
}
const config = context.services.agentContext?.config;
if (!config) {
throw new Error(
`Security configuration not loaded. Cannot verify shell command permissions for '${this.commandName}'. Aborting.`,
);
}
const injections = extractInjections(
prompt,
SHELL_INJECTION_TRIGGER,
this.commandName,
);
// If extractInjections found no closed blocks (and didn't throw), treat as raw.
if (injections.length === 0) {
return [
{ text: prompt.replaceAll(SHORTHAND_ARGS_PLACEHOLDER, userArgsRaw) },
];
}
const { shell } = getShellConfiguration();View on GitHub (pinned to 5024443c72)
Solutions
- Ensure the CommandContext passed to the command/processor includes services.agentContext.config (a loaded Config instance).
- Only invoke commands that use '!{...}' after the agent/config bootstrap is complete.
- If shell injection is not needed, remove the '!{...}' from the prompt so the processor skips the config check entirely.
Example fix
// before
const ctx = { services: { agentContext: undefined } };
await shellProcessor.process(prompt, ctx);
// after
const ctx = { services: { agentContext: { config: loadedConfig } } };
await shellProcessor.process(prompt, ctx); Defensive patterns
Strategy: validation
Validate before calling
function shellProcessorReady(context: CommandContext): boolean {
return !!context.services?.agentContext?.config &&
typeof context.services.agentContext.config.getPolicyEngine === 'function';
} Type guard
function hasConfig(ctx: { services?: { agentContext?: { config?: unknown } } }): ctx is { services: { agentContext: { config: Config } } } {
return !!ctx.services?.agentContext?.config;
} Try / catch
try {
await shellProcessor.process(prompt, ctx);
} catch (e) {
if (e instanceof Error && /Security configuration not loaded/.test(e.message)) {
// wire ctx.services.agentContext.config before invoking commands with !{...}
}
throw e;
} Prevention
- Always wire services.agentContext.config into CommandContext before processing prompts with shell injections.
- Do not invoke shell-injection commands before agent/config bootstrap completes.
- Drop '!{...}' from prompts if shell execution is not required.
When it happens
Trigger: A command containing '!{...}' is processed but the CommandContext has no agentContext (or agentContext.config is unset), so the config lookup returns undefined.
Common situations: Programmatically invoking a ShellProcessor-bound command without wiring services.agentContext.config; a custom integration that constructs CommandContext incompletely; running a shell-injection command before the agent context is initialized.
Related errors
- Invalid syntax${contextInfo}: Unclosed injection starting at
- ${this.commandName} cannot be run. Blocked command: "${comma
- Shell command confirmation required
- Failed to start shell command in '${this.commandName}': ${ex
- Path validation failed: ${pathError}
AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12).
Data as JSON: /api/errors/1de8f5d184396fe8.
Report an issue: GitHub.