{"record":{"id":"1de8f5d184396fe8","repo":"google-gemini/gemini-cli","slug":"security-configuration-not-loaded-cannot-verify-s","errorCode":null,"errorMessage":"Security configuration not loaded. Cannot verify shell command permissions for '${this.commandName}'. Aborting.","messagePattern":"Security configuration not loaded\\. Cannot verify shell command permissions for '(.+?)'\\. Aborting\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/services/prompt-processors/shellProcessor.ts","lineNumber":79,"sourceCode":"      this.processString(text, context),\n    );\n  }\n\n  private async processString(\n    prompt: string,\n    context: CommandContext,\n  ): Promise<PromptPipelineContent> {\n    const userArgsRaw = context.invocation?.args || '';\n\n    if (!prompt.includes(SHELL_INJECTION_TRIGGER)) {\n      return [\n        { text: prompt.replaceAll(SHORTHAND_ARGS_PLACEHOLDER, userArgsRaw) },\n      ];\n    }\n\n    const config = context.services.agentContext?.config;\n    if (!config) {\n      throw new Error(\n        `Security configuration not loaded. Cannot verify shell command permissions for '${this.commandName}'. Aborting.`,\n      );\n    }\n\n    const injections = extractInjections(\n      prompt,\n      SHELL_INJECTION_TRIGGER,\n      this.commandName,\n    );\n\n    // If extractInjections found no closed blocks (and didn't throw), treat as raw.\n    if (injections.length === 0) {\n      return [\n        { text: prompt.replaceAll(SHORTHAND_ARGS_PLACEHOLDER, userArgsRaw) },\n      ];\n    }\n\n    const { shell } = getShellConfiguration();","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/cli/src/services/prompt-processors/shellProcessor.ts#L61-L97","documentation":"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.","triggerScenarios":"A command containing '!{...}' is processed but the CommandContext has no agentContext (or agentContext.config is unset), so the config lookup returns undefined.","commonSituations":"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.","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."],"exampleFix":"// before\nconst ctx = { services: { agentContext: undefined } };\nawait shellProcessor.process(prompt, ctx);\n// after\nconst ctx = { services: { agentContext: { config: loadedConfig } } };\nawait shellProcessor.process(prompt, ctx);","handlingStrategy":"validation","validationCode":"function shellProcessorReady(context: CommandContext): boolean {\n  return !!context.services?.agentContext?.config &&\n    typeof context.services.agentContext.config.getPolicyEngine === 'function';\n}","typeGuard":"function hasConfig(ctx: { services?: { agentContext?: { config?: unknown } } }): ctx is { services: { agentContext: { config: Config } } } {\n  return !!ctx.services?.agentContext?.config;\n}","tryCatchPattern":"try {\n  await shellProcessor.process(prompt, ctx);\n} catch (e) {\n  if (e instanceof Error && /Security configuration not loaded/.test(e.message)) {\n    // wire ctx.services.agentContext.config before invoking commands with !{...}\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["prompt-processor","shell","configuration","security","context"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}