Skip to main content

Does Claude Code block reading .env or ~/.aws/credentials by default?

No. As of October 2026, Claude Code’s sandboxing docs say there is no built-in credential deny list, and its default read access still allows files such as ~/.aws/credentials and ~/.ssh/. Other CLIs offer opt-in deny settings that you write per tool. CC Safety Net blocks reads of .env files, SSH private keys, cloud credential stores, and coding agent auth tokens as soon as it is installed. You can add your own deny paths. Secret protection blocks reads and writes of files that can contain credentials. It runs before command analysis and applies at every safety level. A block names the matched rule id in the block message and the audit log. There are 138 registered rules. Most belong to generated families that share one id pattern, so the tables below list families with their id form rather than every id. Every rule is on by default except the thirteen-rule Coding CLI config tier.

Where it runs

Secret protection checks shell commands and the agent’s read, write, edit, search, and patch tools. It blocks reads as well as writes, so cat .env, strings id_rsa, and dd if=.env all block.

Allow a blocked file

You can allow a protected file in two ways. A per-rule override turns one rule off everywhere. An allow path exempts specific files or directories from every built-in rule except the Coding CLI rules. As an example, take a project that keeps packet captures in captures/. cat captures/session.pcap blocks under secret.ext.pcap.
1

Get the rule id

The block message names it. You can also run npx -y cc-safety-net explain --json 'cat captures/session.pcap' and read ruleId.
2

Edit policy.json yourself

The agent cannot change policy.json, so make the edit in an editor or the dashboard. See Edit the policy file. To turn the rule off:
Or, to exempt one directory:
A relative allow path resolves against the config working directory, as described in Policy. An entry can also be one exact file, such as "captures/session.pcap", or one file name below a folder, such as "~/code/**/.env.local".
3

Confirm the change

Run explain on the same command again. It now shows as allowed.
An allow path never exempts a configured deny path or a secret.cli.* rule. CC Safety Net reports a project file that adds an allow path or turns a rule off as a weakening. See Policy for the override syntax and Secret allow paths for the entries it accepts.

What standard mode does not count as a read

In standard mode, these shapes do not count as reading a built-in sensitive path. Strict and paranoid count every one of them as a read. None of them relax a configured deny path. The look may be one segment of a compound command, such as git check-ignore .env && git status --short. These still count as reads: Creating a file, the tailscale and openssl shapes, and data literals relax only the built-in file-name rules. A home directory or Coding CLI path stays blocked.

Match order

  • CC Safety Net checks configured deny paths first, and they always win.
  • Home directory rules beat the env-template and public-key exemptions, so ~/.ssh/.env.example and ~/.ssh/id_rsa.pub still block.
  • Coding CLI rules (secret.cli.*) ignore allow paths.

Basename rules

Nine rules block an exact basename in any directory. These rules have two limits:
  • secret.basename.credentials matches only the exact name credentials. credentials.json does not match this or any other built-in rule.
  • There is no id_dsa basename rule. An exact id_dsa still blocks, through the broad pattern secret.pattern.ssh-key-basename below.
One pattern rule extends the .env family. secret.pattern.env-variant blocks every basename starting with .env., including .env.local, .env.production, and .env.template.local, except the exempt templates.

Home directory rules

These rules protect locations under the home directory: the directory itself and everything inside it. kube-config and docker-config each have eight companion rules for renamed backups, with the id form secret.home.<slug>.<suffix>. The suffixes are bak, backup, copy, disabled, old, orig, save, and tmp, so ~/.kube/config.bak blocks under secret.home.kube-config.bak.

Key-variant rules

Renamed copies of key and credential files have their own rule family, built from five protected prefixes: id_rsa, id_dsa, id_ed25519, id_ecdsa, and credentials. The slug in each id is the prefix with dashes (id-rsa, credentials, …).
  • Separator variants. The 5 secret.variant.<slug>.separator rules block the prefix followed by - or _ and any text after it: id_rsa-old, id_rsa_backup, credentials_prod.
  • Dot-suffix variants. The 50 secret.variant.<slug>.<suffix> rules block the prefix followed by one of ten suffixes: .bak, .backup, .copy, .disabled, .key, .old, .orig, .pem, .save, .tmp. For example, id_rsa.bak blocks under secret.variant.id-rsa.bak, and credentials.pem blocks under secret.variant.credentials.pem.
The family matches exactly, so lookalikes pass. id_rsafoo matches no separator, and credentials.json uses a suffix outside the list. The family also has one broad pattern. secret.pattern.ssh-key-basename blocks any extensionless basename ending in _rsa, _dsa, _ed25519, or _ecdsa, such as deploy_key_rsa or github_ed25519. A name containing a dot never matches it.

Extension rules

Twenty-one rules with the id form secret.ext.<extension> block any file carrying that extension: .agilekeychain, .asc, .bek, .cscfg, .fve, .gnucash, .jks, .keychain, .kwallet, .mdf, .ovpn, .p12, .pcap, .pem, .pfx, .pkcs12, .psafe3, .rdp, .sdf, .tblk, .tpm Three extension-pattern rules cover extension families: An override must use the family id, secret.ext-pattern.key, not secret.ext.keypair. CC Safety Net rejects an id that is not registered with unknown secret protection rule id "<id>".

Coding CLI credential tier (on by default)

Twelve rules protect the credential stores of supported coding agents. They are on by default. Antigravity has no credential rule. Its only rule is in the configuration tier below.

Coding CLI config tier (off by default)

Thirteen rules cover the settings and MCP configuration files of the same agents. Those files can carry credentials inline, but agents also edit them as routine work, so this tier ships off. Turn a rule on with "on" in secret_protection.overrides. <project> paths then match at any repository root. config.json is a common name, so each rule that matches it is pinned to one directory. secret.cli.opencode.config matches it only inside ~/.config/opencode, and secret.cli.devin.config only inside ~/.config/devin. A config.json in any directory this page does not list stays allowed.

Deny paths

secret_protection.deny_paths adds your own protected files and directories. A hit blocks under secret.deny-path. No override or exemption relaxes it. Only secret_protection.enabled: false turns it off, along with the rest of secret protection.

Exemptions

Three exemptions bound the rules above. None of them relax a configured deny path.

Configuration

All configuration lives in policy.json: Destructive-command allow paths do not relax secret protection. The Dashboard edits the same settings through a UI.
Secret protection is a bounded pattern set, not a general read boundary. A credential in an unrecognized file is not protected. See where CC Safety Net cannot help. Secret redaction, which scrubs credential values from logs and block messages, is separate. See Secret redaction.
Last modified on November 4, 2026