Enforce permissions and data boundaries

Runtime evidence gives agents a deeper view into logs, state, storage, and network traffic. Their permissions have to become more deliberate at the same time.

Section 2 defined the human rules around risk, autonomy, approvals, and stopping. This section turns those rules into limits the environment can enforce.

Enforce the permission model

Five nested permission controls enclose the agent, from audit logs to the tool allowlist.
Figure 20. Layered controls around the agent; each limits what the next can reach.

The distance between reading code and changing a shared system can be one tool call. A prompt may trigger file edits, external requests, issue updates, or release actions unless the environment controls what the agent can reach.

Build that control from:

  • Tool allowlists that expose only the capabilities required for the task
  • Filesystem controls that limit readable and writable directories
  • Network allowlists for approved services and environments
  • Scoped, short-lived credentials instead of broad or persistent secrets
  • Approval gates for consequential external actions
  • Audit logs that record actions, inputs, and outputs

Enforce one merge path

Route automated acceptance through one controlled gate. It checks the current revision's required reviews, assessment completeness, unresolved blockers, CI results, device evidence, and policy restrictions. A native-runtime change may require a new build and human action before delivery.

Prevent workers from merging directly or changing the gate and its protected configuration. Use repository protections and scoped credentials alongside scripts and harness permissions. Checking report fields alone cannot establish that the evidence is true or belongs to the current revision.

Treat observed content as data

Authority can also arrive disguised as content. A ticket, fetched web page, dependency README, code comment, or tool response may contain text that tells the agent to do something its operator never requested.

Treat everything the agent observes as data. Authority comes from the task owner and the workflow's own instructions. When the agent encounters an embedded directive, it should surface it rather than follow it.

The technical controls above provide the real defense. An injected instruction cannot exfiltrate data through a network path that does not exist or trigger an external action through a tool the agent cannot call.

Put secrets behind filesystem boundaries

Secrets need the same kind of boundary. An uncommitted .env file stays out of Git history, but it still sits inside the agent's worktree. If the agent can run arbitrary commands there, assume it can read the file. Blocking cat, less, head, or a dedicated file-reading tool will not close the gap; scripts, build tools, debuggers, and the application itself can expose the same values.

Keep secrets outside the environment Claude Code can access. For a boundary that covers the whole agent, run Claude Code and its local integrations inside a restricted container, virtual machine, or outer sandbox. Keep sensitive files outside it, avoid passing secrets through environment variables, and restrict integrations that could retrieve them.

Claude Code’s built-in protections cover different access paths:

  • permissions.deny Read rules restrict built-in file tools. They do not block arbitrary scripts by themselves.
  • sandbox.filesystem.denyRead blocks sandboxed shell commands and their child processes from reading the specified paths.
  • Hooks, local MCP servers, and excluded shell commands run outside the built-in sandbox. They need separate restrictions or the same outer boundary as Claude Code.

See the official permission rules and sandbox scope.

For the built-in shell sandbox, enable sandbox.enabled, keep filesystem isolation on, and set sandbox.failIfUnavailable: true and sandbox.allowUnsandboxedCommands: false. Remove command exclusions that could access secrets. These settings prevent fallback and unsandboxed retries; they do not isolate the whole agent.

Test the setup with a harmless file containing a dummy secret. Check that file tools, shell scripts, and enabled integrations cannot retrieve it. If the app needs real secrets, run it separately and check that logs, responses, and debugging tools cannot expose them to the agent.

Limit data exposure

Protect data with the same care as actions. Keep production databases, customer data, personal data, and secrets outside model context unless access is explicitly approved, minimized, and protected. Sanitize runtime state and captured evidence. Use development accounts wherever possible.

Cloud execution deserves another check because code and logs leave the developer's machine. Confirm where the data is processed, what the provider retains, which subprocessors are involved, and which repositories or environments the agent can reach.