[BUG] Sandbox `denyWithinAllow` list omits `.git/` prefix from git-internal file paths

Resolved 💬 11 comments Opened Feb 15, 2026 by bpirvu Closed May 25, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

What's Wrong?

The sandbox's denyWithinAllow list constructs incorrect paths for git-internal files. Files that live inside .git/ (such as HEAD, objects, refs, hooks, config) are listed without the .git/ path component, pointing to nonexistent paths at the project root instead.

Actual Behavior

The deny list contains:

/path/to/project/HEAD
/path/to/project/objects
/path/to/project/refs
/path/to/project/hooks
/path/to/project/config

The .git/ segment is missing from every path.

Impact

  1. .git/ internals are unprotected. The deny rules target nonexistent paths at the project root, so the sandbox does not actually block writes to .git/HEAD, .git/objects, etc.
  2. False positives. If a project happened to have files named HEAD, config, objects, refs, or hooks at the root level, they would be incorrectly blocked.

What Should Happen?

Expected Behavior

The deny list should contain:

/path/to/project/.git/HEAD
/path/to/project/.git/objects
/path/to/project/.git/refs
/path/to/project/.git/hooks
/path/to/project/.git/config

Error Messages/Logs

Steps to Reproduce

Steps to Reproduce

  1. Create a standard (non-bare) git repo
  2. Enable sandbox in settings:
{
  "sandbox": {
    "enabled": true,
    "autoAllowBashIfSandboxed": true,
    "excludedCommands": ["git"]
  }
}
  1. Start a Claude Code session in the repo
  2. Ask Claude to show the full denyWithinAllow list
  3. Observe that git-internal files are listed without the .git/ prefix

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.42 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 11 comments on GitHub. Read the full discussion on GitHub ↗