# Claude Code is safe to run on a laptop only after you turn on the sandbox and lock the managed settings

GUIDE, read 12 Nov 2026

**The short answer.** Claude Code ships a permission system, an optional OS sandbox (Seatbelt on macOS, bubblewrap on Linux), hooks, MCP allowlists and OpenTelemetry export. Anthropic's docs say the sandbox is off by default and the working directory limit is a prompt, not a wall. Here is what to set, in order, and what remains.

## How do I secure Claude Code on developer laptops?

Anthropic's security page describes Claude Code as permission based. In Manual mode the tool starts with read-only permissions and asks before it edits files, runs tests or executes commands. A built-in set of read-only commands such as ls, cat and git status runs without asking. Anthropic also documents an Auto mode, in which a separate classifier model reviews actions instead of the user, and says Auto mode is the built-in starting mode for interactive terminal and VS Code sessions.

## The default prompts reduce risk but do not form a boundary

The same page is direct about the limit. The working directory boundary is a permission prompt, so a Bash command a developer approves can still write anywhere the user account can. Anthropic's own wording on untrusted content is that no system is completely immune to attack, and it recommends virtual machines for scripts and tool calls that touch external services.

That framing sets the job. The prompts catch the obvious cases and train developers to read commands. Three controls turn that into something an administrator can rely on: the sandbox for operating system level limits, managed settings so developers cannot loosen them, and telemetry so you can see what ran.

## Permission rules match command text, so pair them with the sandbox

Claude Code evaluates deny rules first. Anthropic's permissions page says a broad deny rule such as Bash(aws *) blocks every matching call, even when a narrower allow rule also matches, and that an allow rule cannot carve an exception out of a deny rule. Matching ask rules also win over allow rules.

A bare tool name in a deny rule, for example Bash, removes the tool from Claude's context entirely. Pattern rules behave differently, and the docs list what they miss. A deny rule on curl does not match the same program invoked by path or inside sh -c, so Anthropic tells teams to pair it with the sandbox network allowlist when the restriction must hold.

File rules have a similar edge. Read and Edit deny rules apply to the built-in file tools, to file commands Claude Code recognizes in Bash such as cat, head, tail, sed and tee, and to redirection targets. They do not apply to a command that reads files without naming them, such as a recursive grep run from the directory that holds the file.

- **Protect secrets files.** Add Read deny rules for paths such as Read(./.env) and Read(./secrets/**). A .claudeignore file has no effect, per the permissions page.
- **Disable the unsafe modes.** Set permissions.disableBypassPermissionsMode and permissions.disableAutoMode to "disable" where you do not want them. Anthropic says these work best in managed settings, where they cannot be overridden.
- **Stop broad allow lists from accumulating.** Claude Code merges permissions.allow across scopes unless the organization sets allowManagedPermissionRulesOnly.

## The sandbox is off by default and covers Bash, not the built-in tools

Anthropic's sandboxing page states that the sandbox is off by default. A developer turns it on with /sandbox, or an administrator sets sandbox.enabled to true. On macOS it uses the Seatbelt framework. On Linux and WSL2 it relies on bubblewrap and socat, and the /sandbox panel shows what is missing.

Inside the sandbox, the docs describe a filesystem that reads most of the machine by default, including credential files such as ~/.ssh and ~/.aws/credentials, unless filesystem.denyRead says otherwise. Writes go to the working directory, a per-user temp directory and any added directories. Network traffic has no direct route out: connections pass through a proxy on the machine that checks each host against network.allowedDomains, which starts empty.

Two caveats matter for a security review. First, the sandbox wraps Bash commands and their child processes. Anthropic says the built-in Read, Edit, Write, WebFetch and WebSearch tools follow permission rules instead, so a denyRead entry does not stop the Read tool and allowedDomains does not limit WebFetch. Second, if the platform cannot support the sandbox or the dependency check fails, Claude Code runs commands without sandboxing by default.

- **Fail closed.** Set sandbox.failIfUnavailable to true so a missing dependency stops startup instead of silently dropping isolation. Anthropic describes this as the setting for managed deployments that treat sandboxing as a security gate.
- **Remove the unsandboxed retry.** Set allowUnsandboxedCommands to false. With the retry disabled, Claude Code ignores the dangerouslyDisableSandbox parameter.
- **Deny credential reads.** Add ~/.ssh, ~/.aws and similar paths to filesystem.denyRead, since the default view of the machine is wide.
- **Start the domain list small.** Leave network.allowedDomains empty and add hosts as builds require them.

## Managed settings are the control developers cannot edit

Anthropic's settings page lists managed settings as the highest scope. They arrive as a managed-settings.json file, an MDM policy or server-managed settings from the claude.ai console. The page states that nothing in a user's own settings files or in the --settings flag overrides a managed key. Managed settings that arrive through MDM or the console reach a running session on a schedule rather than on save.

A practical baseline for a laptop fleet uses these keys, all named in Anthropic's documentation: sandbox.enabled with failIfUnavailable and allowUnsandboxedCommands set as above, permissions.disableBypassPermissionsMode, permissions.disableAutoMode where classifier approval is not accepted, allowManagedPermissionRulesOnly, allowManagedHooksOnly, and the MCP allowlist keys covered below. Anthropic notes that a managed model value is a starting default, not a lock; the locks are availableModels and deniedModels.

One scope gap is worth stating. A managed-settings.json file or MDM profile on a laptop does not reach a cloud session. Only server-managed settings do. If developers also use cloud sessions, plan for both delivery paths.

## Hooks give a pre-execution decision point, and managed policy can restrict who writes them

Claude Code hooks run at defined points in the agent loop. Anthropic's hooks reference lists PreToolUse as firing before a tool call executes and able to block it. Its worked example reads the proposed command on standard input and returns a permissionDecision of deny with a reason. That is the vendor-supported place to add an organization check that sees the command before it runs.

Because hooks are code that runs on the developer's machine, Anthropic lets administrators set allowManagedHooksOnly in managed settings to restrict which hooks run. Its security page also points to ConfigChange hooks to audit or block settings changes during a session. The settings page adds a limit: ConfigChange runs for settings-file changes it detects, not for managed settings that arrive from MDM or the console.

## MCP servers and repository files can add capability that the repository review misses

Project-scoped MCP servers live in .mcp.json, which teams can check into source control. Anthropic's security page warns that reviewing .mcp.json does not show every server a session can load, because servers at other scopes, claude.ai connectors and plugins can add more. It also says Anthropic reviews connectors against listing criteria but does not security-audit or manage any MCP server.

Claude Code shows a workspace trust dialog when it starts in a folder the user has not trusted, and servers in .mcp.json have their own approval prompt. The page notes that a -p (non-interactive) session shows neither prompt. When Claude Code starts directly in a home directory, trust is held for the session only.

The MCP documentation describes the organization controls: a fixed server set through managed-mcp.json, servers provided to every user through managedMcpServers, and restriction through allowedMcpServers and deniedMcpServers. For a developer who must stay inside a known set, the --strict-mcp-config flag makes a session use only servers passed with --mcp-config.

## OpenTelemetry export shows what ran, if you set it in managed settings

Anthropic's monitoring page describes OpenTelemetry export that is off until CLAUDE_CODE_ENABLE_TELEMETRY is set to 1. Events include claude_code.user_prompt, claude_code.tool_decision and claude_code.tool_result, linked by a tool_use_id so a decision can be joined to its result. A prompt.id value groups everything triggered by one prompt.

Claude Code ignores the exporter variables in a repository's .claude/settings.json, so a cloned repository cannot turn telemetry on, change its destination or capture content. Set them in managed settings. Detail is opt-in: OTEL_LOG_TOOL_DETAILS adds Bash commands and MCP tool names, and OTEL_LOG_RAW_API_BODIES, disabled by default, emits full request and response bodies including the whole conversation. Decide deliberately whether command text and prompts belong in your log store.

## An endpoint control covers what the tool's own settings cannot see

Claude Code controls its own behavior. An endpoint control sees the machine around it: other agents, other shells, the packages that arrive, and processes Claude Code did not start. Anthropic's devcontainer page shows why the boundary matters. With --dangerously-skip-permissions, it says, a dev container does not prevent a malicious project from exfiltrating anything reachable inside the container, including the Claude Code credentials in ~/.claude, and it pairs the flag with a firewall script for egress.

Several vendors say they attach to Claude Code's own hook interface to decide before an action runs. CrowdStrike says agent-level hooks for Claude Code, Codex, Copilot and Cursor can inspect prompts and block malicious activity before harmful actions run. Microsoft says agent-native inspection uses vendor event interfaces for Claude Code, Codex CLI and GitHub Copilot CLI to apply audit or block decisions. Pillar says its runtime component sits in the agent's own pre-tool hook for Claude Code, Codex CLI and Cursor. Microsoft also lists a preview known issue: Claude Code may keep processing a tool response in Block mode, and post-response inspection cannot undo completed actions. These are the vendors' claims, read on 12 Nov 2026.

Weigh any of them against what the managed settings already deliver. A hook that duplicates a deny rule adds little. A hook that applies a central decision to every agent on the machine, with a log outside the developer's reach, adds visibility Claude Code's own telemetry cannot provide.

## Where this sits in the index

- [Agent Surface Map](/agent-surface-map/): Which of six agent surfaces each of 16 tools sees
- [Action Control Matrix](/action-control-matrix/): Which of six agent actions each tool can stop
- [The ranked index](/ranking/): 16 tools on seven published criteria

## Related guides

- [Securing Cursor on developer machines](/guides/cursor-security/)
- [Securing GitHub Copilot agent mode and the cloud agent](/guides/github-copilot-agent-mode-security/)
- [Agent surfaces explained](/guides/agent-surfaces-explained/)

## Sources

- Anthropic: Claude Code docs, security: https://code.claude.com/docs/en/security (read 12 Nov 2026)
- Anthropic: Claude Code docs, permissions: https://code.claude.com/docs/en/permissions (read 12 Nov 2026)
- Anthropic: Claude Code docs, sandboxing: https://code.claude.com/docs/en/sandboxing (read 12 Nov 2026)
- Anthropic: Claude Code docs, settings: https://code.claude.com/docs/en/settings (read 12 Nov 2026)
- Anthropic: Claude Code docs, hooks: https://code.claude.com/docs/en/hooks (read 12 Nov 2026)
- Anthropic: Claude Code docs, development containers: https://code.claude.com/docs/en/devcontainer (read 12 Nov 2026)
- Anthropic: Claude Code docs, MCP: https://code.claude.com/docs/en/mcp (read 12 Nov 2026)
- Anthropic: Claude Code docs, monitoring usage: https://code.claude.com/docs/en/monitoring-usage (read 12 Nov 2026)
- CrowdStrike: Falcon Guardian blog post: https://www.crowdstrike.com/en-us/blog/crowdstrike-advances-ai-security-and-safety-falcon-guardian/ (read 12 Nov 2026)
- Microsoft: Defender AI agent runtime protection overview: https://learn.microsoft.com/en-us/defender-endpoint/ai-agent-runtime-protection-overview (read 12 Nov 2026)
- Pillar Security: Agentic Endpoint platform page: https://www.pillar.security/platform/agentic-endpoint (read 12 Nov 2026)

Last reviewed 12 Nov 2026. Canonical: https://aiendpointsecurityranked.com/guides/claude-code-security/
