anthropics / anthropics/claude-code

Allow 'cd + git' commands without security prompt when inside additionalDirectories

未关闭
#91,568 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area:permissions area:security enhancement
主要语言
Python
星标
145k
派生
23.1k
PR 合并指标
PR 指标待抓取

描述

## Problem

When working across multiple related repos configured in `additionalDirectories`, compound commands like `cd ../sister-repo && git push` trigger a blocking security prompt:

> This command changes directory before running git, which can execute untrusted hooks from the target directory. Approve only if you trust it.

This fires **even when**:
1. The target directory is listed in `additionalDirectories` (explicitly trusted)
2. The `Bash(cd * && *)` allow rule is in the project settings
3. A `bypassPermissions` mode is set

The security check appears to bypass the allow list entirely for this specific pattern.

## Why this is painful

Multi-repo projects are a first-class use case (e.g. monorepo adjacents, sister repos). When a project uses `additionalDirectories` to declare trusted repos, `cd repo && git ` is a routine operation that should not require per-invocation approval. The current behavior forces users to either:
- Accept a blanket `bypassPermissions` (too broad), or
- Get prompted on every single cross-repo git operation

## Suggested fix

When the `cd` target resolves to a path inside `additionalDirectories` (or the project directory itself), skip the security warning for the subsequent `git` command — the directory is already explicitly trusted by the project config.

Alternatively, allow the allow-list rule `Bash(cd * && git *)` to suppress this specific warning, since the user has already declared intent.

## Context

Raised by a team using provisioning-hub + provisioning-hub-services + foak-libraries as a three-repo system. Every cross-repo git operation prompts, which creates significant friction in an agentic workflow.

贡献指南

这个仓库没有索引到贡献指南

调研方向

No files or tests are identified. Start by tracing the security check for `cd ... && git ...` and resolution of `additionalDirectories`; reproduce the prompt with a trusted target and an untrusted target, and consider the work complete when trusted targets avoid the warning without weakening protection elsewhere.

由索引模型根据 Issue 内容生成。

评估

技术栈
git
领域
cli, security
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。