google-gemini/gemini-cli · warning

[Configuration] Untrusted workspace detected. Stripping repo

Error message

[Configuration] Untrusted workspace detected. Stripping repository adminPolicyPaths definitions to prevent unintended admin policy override.

What it means

Security warning from loadConfig: when the workspace is not trusted, repository-defined adminPolicyPaths are stripped to prevent a cloned repo from escalating privileges via admin policy files. Loading proceeds; only repo-supplied adminPolicyPaths are ignored.

Source

Thrown at packages/a2a-server/src/config/config.ts:302

  const approvalMode =
    getEnvLocal('GEMINI_YOLO_MODE') === 'true'
      ? ApprovalMode.YOLO
      : ApprovalMode.DEFAULT;

  if (!trusted) {
    if (settings.mcpServers) {
      logger.warn(
        '[Configuration] Untrusted workspace detected. Stripping repository mcpServers definitions to prevent unintended command execution.',
      );
    }
    if (settings.policyPaths) {
      logger.warn(
        '[Configuration] Untrusted workspace detected. Stripping repository policyPaths definitions to prevent unintended policy override.',
      );
    }
    if (settings.adminPolicyPaths) {
      logger.warn(
        '[Configuration] Untrusted workspace detected. Stripping repository adminPolicyPaths definitions to prevent unintended admin policy override.',
      );
    }
    if (settings.tools) {
      logger.warn(
        '[Configuration] Untrusted workspace detected. Stripping repository tools definitions to prevent unintended tool enablement.',
      );
    }
    if (settings.telemetry) {
      logger.warn(
        '[Configuration] Untrusted workspace detected. Stripping repository telemetry definitions to prevent unintended data routing.',
      );
    }
    settings = {
      ...settings,
      mcpServers: undefined,
      policyPaths: undefined,
      adminPolicyPaths: undefined,

View on GitHub (pinned to 0bd1d43975)

Solutions

  1. Enable workspace trust (settings.folderTrust=true or GEMINI_FOLDER_TRUST=true and pass trusted=true to loadConfig)
  2. Move adminPolicyPaths to user-level/global settings so they survive the strip
  3. Remove repo-level adminPolicyPaths if unnecessary
  4. Ignore if intentional: admin policy overrides simply remain at defaults

Example fix

// before
// untrusted workspace + project settings: { "adminPolicyPaths": ["./admin.json"] } -> stripped
// after
export GEMINI_FOLDER_TRUST=true
// or user-level settings:
{ "folderTrust": true, "adminPolicyPaths": ["/abs/path/admin.json"] }
Defensive patterns

Strategy: validation

Validate before calling

export function assertAdminPolicyPathsSurvive(settings: { adminPolicyPaths?: unknown; folderTrust?: boolean }): void {
  const trusted = settings.folderTrust === true || process.env['GEMINI_FOLDER_TRUST'] === 'true';
  if (!trusted && settings.adminPolicyPaths) {
    throw new Error('Workspace is untrusted: repository adminPolicyPaths will be stripped. Enable folderTrust or move admin policies to user settings.');
  }
}

Type guard

function isTrustedWorkspace(s: { folderTrust?: boolean }): boolean {
  return s.folderTrust === true || process.env['GEMINI_FOLDER_TRUST'] === 'true';
}

Prevention

When it happens

Trigger: loadConfig called with trusted=false while settings.adminPolicyPaths is present in project settings; folder trust not enabled (folderTrust=false and GEMINI_FOLDER_TRUST!=true).

Common situations: Repositories that ship admin policy paths for internal tooling being cloned and run without trust; CI environments where the trust env var is absent; upgrading to a version that introduced adminPolicyPaths stripping.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@0bd1d43975 (2026-09-01). Data as JSON: /api/errors/e25f26d6dd59dee7. Report an issue: GitHub.