anthropics / anthropics/claude-code

[BUG] blockReadsOutsideWorkingDirectories prompts for allowlisted gh commands: flag values misidentified as runtime-computed paths

Đang mở
#91,479 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
area:bash area:permissions bug platform:macos
Ngôn ngữ chính
Python
Star
145k
Fork
23.1k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

## Environment
- Claude Code 2.1.258, macOS (darwin)
- defaultMode: auto
- permissions.blockReadsOutsideWorkingDirectories: true
- permissions.allow includes (among others):
- "Bash(gh pr view *)"
- "Bash(gh api:*)"
- "Bash(grep:*)", "Bash(head:*)"

## Steps to reproduce
1. Set blockReadsOutsideWorkingDirectories: true and add an explicit allow rule for gh, e.g. "Bash(gh pr view *)".
2. Ask Claude to run a gh command whose arguments are a PR number, an --repo slug and a --jq expression, e.g.:

gh pr view XXXX --repo org/repo --json reviews --jq '.reviews[] | "\"\(.submittedAt[0:10]) \(.state) \(.author.login)\""'

## Actual result
A permission prompt fires with the message:

> gh names a path that is computed at run time, which cannot be checked against the read block (permissions.blockReadsOutsideWorkingDirectories)

The prompt appears even though the command is covered by an explicit user-configured allow rule. The user must confirm every such gh invocation manually.

## Expected result
Either of:
- an explicit allow rule (Bash(gh ...) or Bash(gh api:*)) should satisfy the read-block gate for that command, or
- the read-block pre-check should not classify gh flag values (--repo slug, --jq expressions, URLs) as runtime-computed file paths — they are network/URL arguments, not paths under cwd.

## Additional notes
- The heuristic is inconsistent: some gh invocations that also carry --repo/--jq pass without a prompt, others trip it. It looks like a token-level heuristic misfiring on certain strings (quotes, brackets, slashes in flag values).
- Related behavior observed in the same session: after the user manually declines a specific command once, an identical command re-prompts on later invocations even when an allow rule matches. If that is by design it would be worth documenting, since combined with the above it produces repeated unavoidable prompts.
- Practical impact: with blockReadsOutsideWorkingDirectories enabled, gh/api-heavy workflows become unusable without answering prompts, which defeats the purpose of a configured allowlist.

Happy to provide more config details if useful.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Reproduce with permissions.blockReadsOutsideWorkingDirectories enabled and an allow rule such as Bash(gh pr view *), using the reported gh pr view command with --repo and --jq values. Trace the read-block pre-check and command-argument classification; done means covered gh invocations no longer receive false path prompts while genuine outside-working-directory reads remain checked.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
github
Lĩnh vực
cli, security
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.