◉CLAUDE LABJP
●2.1.293 — v2.1.293 makes Claude Haiku 5.5 the default Haiku model (1M context)●SONNET 4.5 — Retires on the Claude API on 11/30, 53 days left. Migrate to Sonnet 5.5●API CACHE — Sonnet 5.5 cache reads drop to $0.10/Mtok (Oct 7)●Q&A — People are asking what to cut first when always-loaded instruction files grow too big●HAIKU 5.5 — Code written for Haiku 4.5 hits a 400 error on budget_tokens●NEW — If Pro looks unpaid, where you bought it decides which screen to check●2.1.293 — v2.1.293 makes Claude Haiku 5.5 the default Haiku model (1M context)●SONNET 4.5 — Retires on the Claude API on 11/30, 53 days left. Migrate to Sonnet 5.5●API CACHE — Sonnet 5.5 cache reads drop to $0.10/Mtok (Oct 7)●Q&A — People are asking what to cut first when always-loaded instruction files grow too big●HAIKU 5.5 — Code written for Haiku 4.5 hits a 400 error on budget_tokens●NEW — If Pro looks unpaid, where you bought it decides which screen to check
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-code132sandbox9security18credentials3automation109secrets

✦ 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 $15 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, what happens when the secret rides in the body, and where chunked framing makes the substitution miss entirely.
⟐ 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-08-28
A small script that catches invisible characters in plugin names before you install
Control characters and zero-width characters hiding in plugin or skill names are invisible in a terminal listing. I built six deliberately confusing names, compared what ls actually shows, and wrote a short check you can run before installing anything — plus an honest note on what that check misses.
📚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