Study FAQ
How do Claude Code permission rules and shell sandboxing protect the same file?
Also asked as 2
- Which Claude Code rules protect a sensitive file from both Read and shell subprocess access?
- How do deny rules and the shell sandbox work together to restrict file access in Claude Code?
Answer
Claude Code evaluates matching permission rules in deny, ask, then allow order. A narrower allow cannot override a matching deny. Use ask rules for actions that need confirmation and reserve allow rules for reviewed routine work. A blanket Bash ask rule can be skipped for sandboxed commands in sandbox auto-allow mode. Use rules for the built-in tools and use OS sandbox controls for access by shell commands and their child processes. A file rule alone cannot constrain arbitrary unsandboxed processes.
With shell sandboxing enabled on a supported platform, check the effective filesystem and network limits. Claude Code incorporates applicable Read deny rules into the sandbox's read-denial list. The built-in Read tool and shell commands use different enforcement paths, so verify each relevant path. A separate sandbox denyRead entry restricts sandboxed shell access. Use permission rules to restrict built-in Read.
Restrict inherited environment variables and prefer short-lived, narrowly scoped credentials. Review paths outside the shell sandbox, including command hooks, local MCP servers, excluded commands and any permitted unsandboxed retries. Use appropriate process isolation for them, restrict credentials at the destination, and keep allow rules specific to reviewed routine operations. Managed-only permission policy can limit which settings sources contribute rules.
Claude Code permission rules · Claude Code shell sandboxing · Claude Code settings
Full explanation
Claude Code Context, Settings, and Permission Architecture
Study guide · CCAR-F
Read the full explanation