CLAUDE LABJP
VERSION — v2.1.227 landed on August 10 with no new features, just fixes around plan detection and CI behaviorAUTO — Two days remain until August 14, when auto mode becomes the default in Claude Code for Pro, Max, and TeamCI — Bash commands no longer fail across the board under claude-code-action with allowed_non_write_users on GitHub-hosted runnersBILLING — Sessions started with an expired token could misread your plan and nudge Max users toward usage credits; that is now fixedSUNSET — The legacy Workbench and the experimental prompt tool APIs retire on August 17, five days outPRICE — Sonnet 5 promo pricing at $2/$10 per Mtok runs through August 31, moving to $3/$15 on September 1VERSION — v2.1.227 landed on August 10 with no new features, just fixes around plan detection and CI behaviorAUTO — Two days remain until August 14, when auto mode becomes the default in Claude Code for Pro, Max, and TeamCI — Bash commands no longer fail across the board under claude-code-action with allowed_non_write_users on GitHub-hosted runnersBILLING — Sessions started with an expired token could misread your plan and nudge Max users toward usage credits; that is now fixedSUNSET — The legacy Workbench and the experimental prompt tool APIs retire on August 17, five days outPRICE — Sonnet 5 promo pricing at $2/$10 per Mtok runs through August 31, moving to $3/$15 on September 1
Articles/Claude Code
Claude Code/2026-06-25Advanced

Your Sandbox Can Run the Code but Shouldn't Read Your Credentials — Shrinking the Secret-Read Surface with sandbox.credentials

Claude Code's sandbox can still read ~/.aws/credentials and token env vars by default. Using sandbox.credentials (v2.1.187+), here is how I tightened the secret-read surface of unattended runs at the OS level, with config and verification you can reuse.

claude-code129sandbox9security15credentials3automation101secrets2

Premium Article

I run Claude Code unattended on a fixed daily schedule, letting it build and test code inside the sandbox. One day I was idly looking at the sandbox read scope in the /sandbox Config tab, and I stopped. Writes were scoped down to the working directory and a temp area, but reads were still open to the entire machine — and that scope included ~/.aws/credentials and ~/.ssh/. A child process of some npm test the agent piped in could, in principle, read those files.

I had naively assumed the sandbox was a mechanism for "running code safely," but the default read policy was far broader than I imagined. As an indie developer running the Dolice Labs sites unattended, that read scope sat closer to my secrets than I was comfortable with. This article shares the actual work of shrinking that read exposure at the OS-enforcement level using sandbox.credentials, added in v2.1.187. If you don't pin down exactly what it blocks and what it doesn't, you leave a hole while feeling reassured — so I'll center the piece on that boundary.

Why the default read policy is open to the whole machine

The sandbox's default behavior is asymmetric between writes and reads. Writes are scoped to the working directory and its subdirectories, plus the session temp directory that $TMPDIR points to. Reads, by contrast, are open to the "entire machine" except for a few denied directories.

There's a reason for the asymmetry. Builds and tests often can't run unless they can read outside the working directory — tool caches under your home directory, shared system libraries, global config files, and so on. Scoping reads down to only the working directory breaks most toolchains. So the default opens reads wide and closes only writes tightly.

The problem is that this "wide-open read" includes your credentials. The official docs say it plainly: the default read policy still allows reading ~/.aws/credentials and ~/.ssh/. In an unattended pipeline this matters in a quiet but real way. The commands an agent generates and runs aren't always the same, and the moment a command that reads a credential file slips through, the sandbox itself does nothing to stop it.

What sandbox.credentials blocks, and what it doesn't

sandbox.credentials declares the credential files and environment variables that sandboxed commands must not access. Its behavior splits into two channels.

One is files. Paths listed here are denied for reads inside the sandbox — the same read block that filesystem.denyRead applies. The other is envVars. Variables listed here are unset before each sandboxed command runs. The point is that you can write the credential-file read denial and the secret-environment-variable removal together in a single credentials block.

Conversely, you need to know precisely what it does not stop. The table below organizes the scope of sandbox.credentials.

TargetEffect of sandbox.credentials
Sandboxed Bash commands and their child processesfiles are read-denied; envVars are unset before each run
Built-in Read / Edit / Write file toolsOut of scope (governed by the permission system, not the sandbox)
Access via MCP serversOut of scope
Exfiltration over the networkOut of scope (controlled separately by domain allowlist and proxy)
Commands that run with the sandbox disabledOut of scope (they follow the regular permission flow)

So sandbox.credentials is a part that plugs only the "read path of sandboxed Bash." Having the built-in Read tool open a credential file, or having contents shipped out to a broad domain you allowed, must be defended at a different layer. Conflate these and you close one side while feeling safe. If you want to design secret handling end to end, reading Claude Code Secret Management and Trust Boundary Design, which covers how to partition trust boundaries, makes it clearer which layer sandbox.credentials belongs to.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Understand structurally why the sandbox's default read policy is open to the whole machine, credential files included
Reuse a Before/After sandbox.credentials config that separates files (denyRead) from envVars (unset)
Take away the in-sandbox commands that verify the policy and a minimal watchdog that guards against regression
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Claude Code2026-08-05
Passing the Request, Not the Secret — Where Sandbox Credential Masking Works and Where Substitution Breaks
Claude Code's sandbox credential masking lets processes read sentinel values while a proxy swaps in the real secret at send time. I rebuilt it as a minimal proxy and measured which auth schemes survive the swap, which break, and what happens when the secret rides in the body.
Claude Code2026-08-04
Tightening Filesystem Isolation Separately from the Network — Collect the Paths, Then Squeeze the Write Surface
Claude Code v2.1.216 lets you control filesystem isolation independently from network isolation. Before tightening anything, I traced what a real job actually touches, split reads from writes, and measured how stable the path set is across repeated runs. The numbers changed how I wrote the allowlist.
Claude Code2026-04-25
Secret Management and Trust Boundaries for Claude Code — A Production Guide for the Agent Era
A field-tested approach to secrets in a Claude Code workflow: trust-boundary modeling, three injection patterns, leak-prevention hooks, and rotation runbooks — with working code for .env, MCP, and OS Keychain integrations.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →