Claude Code Security: How to Bound and Test Agent Access<
A developer asks Claude Code to repair a test. The repository contains a fixture that tells the agent to load a local credentials file and upload it to a diagnostic service. The agent proposes a shell command that would do both.
Before approving the command, the developer needs to know which account would run it, whether the file is reachable, and whether the network allows the destination. Those answers come from the execution environment and service permissions.

Conceptual diagram. Files, credentials, commands, and egress a session can reach.
Inventory what the session can reach
Review the environment that developers actually use. A local terminal session, a managed cloud session, and unattended automation can have different settings, credential sources, and approval behavior. Record the product version, deployment surface, and applicable settings before interpreting the results.
| Area | What to inventory | Why it matters |
|---|---|---|
| Files | Workspace, mounted paths, home directory, symlinks, caches | An approved shell command may have broader access than an editor tool |
| Commands | Shell, package managers, build scripts, hooks, subprocesses | A short command can invoke code from several other sources |
| Credentials | Environment, credential helpers, SSH agent, mounted files, service tokens | The process may act with credentials outside the repository |
| Network | Shell egress, model requests, connectors, proxies, package registries | Each channel can have a different enforcement point |
| Extensions | Installed plugins, MCP servers, project settings, IDE components | Some components can run outside the model-mediated tool path |
Anthropic documents that permission modes govern prompts and approvals. Its security documentation also distinguishes workspace prompts from operating system restrictions on Bash commands. For the version and surface you use, verify effective behavior instead of inferring it from a settings file. Claude Code security documentation
Define the workspace and isolate execution

Conceptual diagram. Permission and isolation boundaries.
Use a dedicated development account or disposable environment for the work. Mount only the repository and supporting data needed for the task. Keep production credentials and unrelated repositories outside the environment. Review what the selected sandbox covers and where it allows exceptions.
Treat repository content as input from a potentially untrusted source. Test fixtures, package scripts, issue text, and repository instructions may all influence the agent or invoke code. The effect depends on what can run and what that process can reach.
A workspace prompt and an OS permission can protect different paths. Verify file access through the editor and through shell subprocesses. Test a symlink from inside the workspace to an external synthetic file if your threat model includes path escape.
Limit commands, connectors, and credentials
List the commands needed for routine development. Separate ordinary tasks such as local tests from actions that install dependencies, change release configuration, or publish code. Review permission rules and exceptions in the environment where the work runs. Put hard filesystem and network restrictions at layers that can enforce the boundary even if a command looks harmless.
Use short-lived credentials scoped to the repository and action. A read-only token can support review without authorizing a push. Keep deployment and signing credentials in controlled services where possible. Test whether a subprocess can read an inherited test token or use a socket that was intended for a different task.
Apply network limits to the routes you actually use. Test shell egress separately from connector traffic and model requests. If a connector can send data to a third-party service, review that path and the service credentials independently.
Keep consequential approvals tied to the action
Define which actions require a person to approve them. Use a trusted approval surface and record the command or operation, target, identity, parameters, and expiry. For production deployment, changes to release permissions, or sensitive exports, keep final authorization in the destination system or an independently controlled workflow.
Review how the session behaves when the approval is declined, missing, or stale. Approval for one branch or target should not authorize a different one. Branch protection and release controls provide a separate check where a change takes effect.
Review extension trust separately
In controlled tests published October 30, 2026, CERT-EU placed backdoors in third-party extensions loaded by Pi 1.3.0 and Claude Code 2.1.304. These were research environments used to demonstrate credential collection through an extension. The cited research did not report a backdoor shipped in the Claude Code 2.1.304 core release. CERT-EU research
Inventory approved extension sources, permissions, and versions. Review what a project can configure and what users or administrators can install outside the repository. Verify which components run under the developer’s account and what restricts their access. A model tool rule may have no effect on a component that acts independently.
Keep evidence you can use
Capture who launched the session, the action that was attempted, the policy and approval decision, and what the destination observed. Correlate events across the agent, sandbox, and service. Restrict access to the records and redact sensitive material. Avoid capturing full prompts and environment dumps by default.
When diagnosing a denied action, determine which control actually blocked it. A network restriction, destination authorization failure, and prompt refusal give different evidence. The test report should name the boundary that held and any routes it did not cover.

Proposed checklist. Acceptance test matrix.
Run a controlled acceptance test
Start in a disposable workspace with synthetic credentials, a test repository, and a network destination you control. Verify a legitimate task first. Then introduce the fixture from the opening scenario and attempt the denied paths directly as well as through model prompts.
| Test | Expected outcome | Evidence |
|---|---|---|
| Edit an approved test file and run local tests | Work succeeds within the workspace | Diff and test output |
| Read a synthetic file outside the permitted scope | The configured boundary blocks the read on covered paths | Tool or sandbox event and access result |
| Connect to an unapproved test destination | Egress is blocked on the intended channel | Network policy decision and destination logs |
| Push to a protected branch without release approval | The repository refuses the change | Git service response and branch state |
| Invoke a disabled extension or connector | The capability remains unavailable through the tested launch path | Effective inventory and execution record |
| Revoke a scoped credential with work queued | Fresh actions are rejected and in-flight work reaches a known state | Revocation time, refused request, and service-side state |
Retest after changes to permission modes, package and plugin versions, mount configuration, or credentials. Assign an owner who can disable the workflow and revoke downstream access. Keep a tested manual path for release or recovery work that must continue while the agent is restricted.
For CSI’s existing product-specific reference, see Claude Code Security.