name: secret-read-guard
description: Refuse tool calls that would print a secret file, helper output, keychain or environment; use masked reader.
Secret read guard
Every other golems gate guards writes. This one guards reads: on 2026-11-17 a
Codex worker printed the Claude-proxy key with a plain cat of a settings
file, and nothing stopped it.
What it refuses
A Bash, Monitor, Read or Grep call that would put a secret on screen:
- A listed file. The list is data:
secret-files.json (paths, basenames,
Claude settings whose env block holds a secret-named key, and every
*.bak-*, ~, .orig, .old and .swp backup), matched the way APFS
names files: case-insensitive and
Unicode-normalization-insensitive (.ENV is .env; composed é is
e + U+0301).
cat, head/tail, less, bat, any sed (in-place included: its
w command can print), awk, grep (not -c/-l/-L/-q),
jq (except a key-only filter such as keys), base64, xxd, strings,
diff, editors, git show HEAD:<file>, interpreters given the file,
curl -d @file, < file into anything but a counter or hash, and a copy or
move of the file to a path the list does not cover (cp .env /dev/stdout,
cp auth.json notes.txt). Any command not known to be safe is refused when
an operand resolves to a listed file.
- MCP configs.
.mcp.json in any folder, ~/.claude.json and Claude's
.claude.json.backup* copies are listed names, so every shape above
applies to them: cat/head/sed/grep/jq . over them, python3 -c
code that opens them, python3 -m json.tool, the Read tool and content
Grep. Absolute paths, $HOME/.claude.json, other folders and symlinks to
them are covered (the link's real path is checked). Servers keep tokens
inline under mcpServers.<name>.env or headers, which is how a live
token reached transcripts 49 times in the 30 Nov 2026 leak review. Safe:
jq '.mcpServers | keys' .mcp.json, ls, wc -c, .mcp.json.example,
and the masked reader, which keeps server names, command, args, type
and url readable. A content Grep over a folder that holds a .mcp.json
is refused like one that holds a .env: pass a glob or a narrower path.
- Process command lines.
ps forms that print an argument column print
every key passed on a command line: ps aux, ps -ef, bare ps, ps -A,
ps -p <pid> (macOS's default format ends in the full command line),
-o/--format lists with args, command or cmd, -O, and any
default-format flag (-f, -l, -j, -v, -u, BSD u/v/j/l/s)
next to -o. Also pgrep/pkill with -a/--list-full, or -l with
-f, and /proc/<pid>/cmdline. Safe forms, which the refusal names:
pgrep -x <name> or pgrep -f <pattern> (pids only), pgrep -l <name>
without -f/-a (pid and name), ps -axo pid,ppid,stat,etime,comm (any
-o list without an argument column), and the masked listing
python3 <reader> --ps [filter].
- Links and moves.
ln, ln -s, cp -l/-s of a listed file, and mv
from or onto a listed path. The whole command is judged before any of it
runs, so a link made in it is invisible to a later read: every name this
command links (or copies a listed file to) is an alias, and reading it later
in the same command is refused.
- A file it can't name. A printing command whose file is only known at
run time (
f=$(grep -l ...); cat "$f", xargs input, while read f) is
refused: fail-closed. The refusal says to run the lookup first and name the
file literally. Globs, ~, $HOME, inherited environment variables,
variables the command assigns itself (F=x.md; cat "$F"), for f in a b
lists, cd targets, and find -name '*.ts' -exec head {} + (a name pattern
that can't match a listed file, outside secret folders) are resolved. For
find ... -exec <printer>, a literal listed name (-name .mcp.json) is
refused outright; a wildcard filter is checked against the real tree: the
start folders are walked (every depth, case-folded matching, symlinks
judged by their target) and the command is refused if any matching file is
listed, so -name '*.bak-review' meets .mcp.json.bak-review. A pattern
can't be proved disjoint from the list in the abstract (.env.* and the
.bak-* backup suffix absorb any extension), which is why the tree is
walked. Over 1.5 s or 200,000 entries, character classes and escapes fail
closed.
- Commandless reads.
$(< file) substitutes the file's content and zsh
pages a bare < file, so echo $(< .env), cat <<< $(< .mcp.json) and
< ~/.claude.json are judged like cat. Output-only redirects
(> out.txt) stay allowed.
- Anything over 32 KiB. A command too large for the policy parser is
refused whatever it names (split it, or pass long content by file path);
git-guardian refuses those too.
- A recursive search into a secret folder (
grep -r, rg, content-mode
Grep) that prints lines, including a symlink into that folder. Content-mode
Grep over a directory enumerates with rg --files --hidden --no-follow,
excludes .git, .svn, .hg, .bzr, .jj and .sl, and uses Claude's
whitespace/comma glob splitting (brace alternations stay together) and type.
Any listed candidate refuses the search regardless of the content pattern.
Resolution tries PATH, Claude's embedded rg (CLAUDE_CODE_EXECPATH with
argv0 rg), Homebrew locations, then vendored rg under Claude's install.
Without rg, a bounded Python superset walk includes hidden and gitignored
files, ignores glob/type filters, prunes those six VCS dirs and skips links.
Clean trees allow on either path. Enumeration fails closed after 2 seconds,
40,000 entries or 2 MiB of names, or on a tool error. Brace/class and
specimen pre-checks apply only when the path is not a directory.
- A secret helper: running
claude-proxy-token (the apiKeyHelper).
- The keychain:
security find-generic-password / find-internet-password
with -w or -g, and security dump-keychain.
- Environment dumps, in any form or pipeline, no exceptions:
env with no
command (env -0 too), printenv (any argument), export bare or -p,
bare set, declare/typeset bare or with -p/-x, compgen -e;
echo/printf/launchctl getenv of a secret-named variable; ps -E,
ps e, ps eww; launchctl print|export|procinfo; /proc/*/environ.
env NAME=value cmd (env as a wrapper) still runs. Variable names only?
Use a script file.
- Inline interpreter code that touches the environment at all. For
python, node, ruby, perl, php, deno, bun, osascript and the rest: inline
code in any spelling (
-c/-e, clustered -Ic/-sc, attached -cCODE,
--eval=CODE, -p, -r, deno eval, -, a heredoc or here-string with
no script file) is refused if it references os.environ, environ,
getenv, process.env, ENV, %ENV, Deno.env, Bun.env, AppleScript
system attribute / do shell script, Swift ProcessInfo/.environment,
Scala sys.env, or Tcl $env(, env(,
array get env, parray env. The same goes for awk-family ENVIRON and
jq/yq env, $ENV, strenv (a .env field is fine). Code piped on stdin
into any interpreter or shell (echo 'puts $env(K)' | tclsh,
echo printenv | sh, cat <<EOF | node) is inline code too; a variable in
it means the code only exists at run time, so it is refused. Output of
another command piped in (cat tool.py | python3) counts as a script file.
A heredoc or here-string fed to any shell, eval's arguments and
source /dev/stdin <<EOF are judged as shell text; source <(...) is
refused. busybox/toybox <applet> is judged as the applet.
No name matching: aliases (e=os.environ; print(e)) leave nothing to match. It is
also refused if it names a listed path, opens a listed name
(open('.env')) or runs the helper. Code that needs a key belongs in a
script file; ( set -a; . x.env; set +a; python3 tool.py ) keeps working.
The masked reader
python3 ~/.claude/hooks/secret-read-guard/scripts/masked-read.py <file>
Exactly that argv: python3 <reader> <files>. Any interpreter option
(-I, -X, -c, -m, -W...) or other shape, direct execution included,
is not exempt. It prints the file's structure with every value replaced by
<redacted len=N sha=xxxxxxxx> (JSON, YAML, env and TOML aware; unknown
formats print key names only; comments are dropped). Equal values share a
sha, so two files can be compared without showing either.
MCP configs stay auditable: inside any JSON mcpServers object, server
names and plain fields (command, args, type, url, cwd, numbers)
print as they are, while everything under env and headers, any field
whose key names a credential (token, secret, password, api key, auth,
cookie...), the whole argv element after a credential-named flag in args
(even one starting with -), the whole value of a credential-named
name=value / Name: value element (spaces included), URL passwords,
query values whose percent-decoded name names a credential (api%5Fkey),
explicit Bearer/Basic/Token values at any length, and strings with a
credential shape (sk-, ghp_, sbp_, xox*-, AKIA, JWTs, long random
tokens) are redacted. Once inside env, headers or a credential-named key,
every descendant is redacted; a mcpServers nested there never becomes
readable. A .claude.json prints only its non-empty mcpServers objects,
keyed by path (projects > /repo > mcpServers); its other keys hold
history and account data.
python3 ~/.claude/hooks/secret-read-guard/scripts/masked-read.py --ps [filter...]
prints pid ppid command for every process, with the same credential shapes
redacted in each command line. A flattened command line has lost its argv
boundaries, so from the first credential marker on (a dash-flag naming a
credential, NAME= / Name: naming one, or Bearer/Basic) the rest of
the line is redacted whole: a dash-leading, quoted or spaced value can't be
told apart from the next argument. Filters are case-insensitive substrings
matched against the redacted line, so a filter can't probe a hidden value.
Shapes are a heuristic: a key with no recognizable shape, passed positionally
after a flag whose name doesn't say credential, still prints. Prefer the pid
and name forms when they answer the question.
The guard exempts exactly this file (by real path), not a look-alike. The refusal message names
the reader's path.
Allowed
ls, stat, test -f, wc -c, shasum, chmod, grep -c, jq 'keys',
. file.env / source with a script or binary after it (the sanctioned way
to use a key), env NAME=value cmd,
cp x.env x.env.bak-<date>, reading .env.example, jq '.mcpServers | keys' .mcp.json, pgrep -x/-f/-l (without -f and -l together, and without
-a), ps -axo pid,ppid,stat,etime,comm, and every command that names no
listed file.
Known limits
This guard is a speed bump plus an audit trail, not a sandbox. It parses
shell text and cannot enumerate every interpreter, applet, encoding or
indirection an agent could use to read a file or the environment. The primary
control is keeping secrets out of agent-readable files: the keyout lane's
apiKeyHelper plus the macOS keychain. Treat a refusal as a nudge toward the
masked reader or a script file, and a pass as "no known shape matched", never
as proof that nothing leaked.
Specific gaps known today:
Other process viewers that print command lines (pstree, htop,
procs, sysctl kern.procargs2) are not parsed; ps and pgrep cover
the shapes seen in transcripts. The ps parser judges macOS and procps
spellings and fails closed on run-time input, but an exotic option spelling
it misreads can still pass. It also over-refuses a few harmless forms
(ps -axo pid,comm -X, ps -axo pid,args -c); use a plain -o list.
The find walk sees the tree as it is when the hook runs; a file created
between the check and the run is not seen (the same race content Grep
has). A start folder too big to walk inside the bound is refused; name a
narrower folder.
Interpreter scripts (python3 tool.py) are not read; only their operands
and inline code are checked. Languages with only file runners (go run)
are the same.
Shell text is judged with bash meanings: fish's set -x / set --show
list exported variables there, but set -x is tracing in bash, so it is
not refused. Paths built at run time in code
(os.path.join(home, ".codex", "auth.json")) are out of reach.
source x.env && echo "$VAR" is caught only when the variable name looks
secret (token, secret, password, api_key, credential...).
Bash recursive searches inside ordinary repos are not walked; rg skips
hidden files by default, grep -r does not. Directory content-Grep now
checks hidden candidates with Claude's rg flags and retains rg's ignore
rules. Without rg the superset walk may deny a glob/type-filtered search
because it also checks ignored or excluded files. Repos over the enumeration
cap refuse content Grep; use a narrower path. Filesystem changes between
the check and the actual search remain a TOCTOU race.
Editing a listed file needs a path that never prints it: Claude's Edit tool
needs a Read first (refused), and inline code that opens the file is
refused. Use a script file or the tool that owns the file.
These limits are why the keyout lane also takes secrets out of readable
files. This guard narrows the accident; it is not a sandbox.
Measured
Replaying distinct real Bash commands from local Claude transcripts (scratch
HOME, no real file read): round 0, 369 of 25,702 refused (1.44%); round 1
(stricter env, sed and inline-code rules), 379 of 24,904 (1.52%); round 2
(final class rules: any env reference in inline code, no env-dump
exceptions), 431 of 24,892 (1.73%); round 3 (awk/jq/AppleScript/Tcl env
reads, piped stdin code), 432 of 24,880 (1.74%). About 60% of refusals name a file only at
run time; most of the rest touch a listed file or the environment. Hook median
81 ms.
Wiring
Claude: PreToolUse on Bash|Monitor|Read|Grep, fail-closed launcher.
Codex 0.171: native PreToolUse hook on ^Bash$ through
scripts/hooks/codex-policy-hook.py (Codex has no Read tool; shell is its
read path). Codex runs a new hook only after the owner trusts it from plain
codex via /hooks. Each denial appends ts, input_sha256 and rule to
~/.claude/logs/secret-read-guard-ledger.jsonl (override:
SECRET_READ_GUARD_LEDGER), never the command text.
1---2name: secret-read-guard3description: Refuse tool calls that would print a secret file, helper output, keychain or environment; use masked reader.4---5---6name: secret-read-guard7description: Refuse tool calls that would print a secret file, helper output, keychain or environment; use masked reader.8---910# Secret read guard1112Every other golems gate guards writes. This one guards reads: on 2026-11-17 a13Codex worker printed the Claude-proxy key with a plain `cat` of a settings14file, and nothing stopped it.1516## What it refuses1718A Bash, Monitor, Read or Grep call that would put a secret on screen:1920- **A listed file.** The list is data: `secret-files.json` (paths, basenames,21 Claude settings whose `env` block holds a secret-named key, and every22 `*.bak-*`, `~`, `.orig`, `.old` and `.swp` backup), matched the way APFS23 names files: case-insensitive and24 Unicode-normalization-insensitive (`.ENV` is `.env`; composed `é` is25 `e` + U+0301).26 `cat`, `head`/`tail`, `less`, `bat`, any `sed` (in-place included: its27 `w` command can print), `awk`, `grep` (not `-c`/`-l`/`-L`/`-q`),28 `jq` (except a key-only filter such as `keys`), `base64`, `xxd`, `strings`,29 `diff`, editors, `git show HEAD:<file>`, interpreters given the file,30 `curl -d @file`, `< file` into anything but a counter or hash, and a copy or31 move of the file to a path the list does not cover (`cp .env /dev/stdout`,32 `cp auth.json notes.txt`). Any command not known to be safe is refused when33 an operand resolves to a listed file.34- **MCP configs.** `.mcp.json` in any folder, `~/.claude.json` and Claude's35 `.claude.json.backup*` copies are listed names, so every shape above36 applies to them: `cat`/`head`/`sed`/`grep`/`jq .` over them, `python3 -c`37 code that opens them, `python3 -m json.tool`, the Read tool and content38 Grep. Absolute paths, `$HOME/.claude.json`, other folders and symlinks to39 them are covered (the link's real path is checked). Servers keep tokens40 inline under `mcpServers.<name>.env` or `headers`, which is how a live41 token reached transcripts 49 times in the 30 Nov 2026 leak review. Safe:42 `jq '.mcpServers | keys' .mcp.json`, `ls`, `wc -c`, `.mcp.json.example`,43 and the masked reader, which keeps server names, `command`, `args`, `type`44 and `url` readable. A content Grep over a folder that holds a `.mcp.json`45 is refused like one that holds a `.env`: pass a `glob` or a narrower path.46- **Process command lines.** `ps` forms that print an argument column print47 every key passed on a command line: `ps aux`, `ps -ef`, bare `ps`, `ps -A`,48 `ps -p <pid>` (macOS's default format ends in the full command line),49 `-o`/`--format` lists with `args`, `command` or `cmd`, `-O`, and any50 default-format flag (`-f`, `-l`, `-j`, `-v`, `-u`, BSD `u`/`v`/`j`/`l`/`s`)51 next to `-o`. Also `pgrep`/`pkill` with `-a`/`--list-full`, or `-l` with52 `-f`, and `/proc/<pid>/cmdline`. Safe forms, which the refusal names:53 `pgrep -x <name>` or `pgrep -f <pattern>` (pids only), `pgrep -l <name>`54 without `-f`/`-a` (pid and name), `ps -axo pid,ppid,stat,etime,comm` (any55 `-o` list without an argument column), and the masked listing56 `python3 <reader> --ps [filter]`.57- **Links and moves.** `ln`, `ln -s`, `cp -l`/`-s` of a listed file, and `mv`58 from or onto a listed path. The whole command is judged before any of it59 runs, so a link made in it is invisible to a later read: every name this60 command links (or copies a listed file to) is an alias, and reading it later61 in the same command is refused.62- **A file it can't name.** A printing command whose file is only known at63 run time (`f=$(grep -l ...); cat "$f"`, xargs input, `while read f`) is64 refused: fail-closed. The refusal says to run the lookup first and name the65 file literally. Globs, `~`, `$HOME`, inherited environment variables,66 variables the command assigns itself (`F=x.md; cat "$F"`), `for f in a b`67 lists, `cd` targets, and `find -name '*.ts' -exec head {} +` (a name pattern68 that can't match a listed file, outside secret folders) are resolved. For69 `find ... -exec <printer>`, a literal listed name (`-name .mcp.json`) is70 refused outright; a wildcard filter is checked against the real tree: the71 start folders are walked (every depth, case-folded matching, symlinks72 judged by their target) and the command is refused if any matching file is73 listed, so `-name '*.bak-review'` meets `.mcp.json.bak-review`. A pattern74 can't be proved disjoint from the list in the abstract (`.env.*` and the75 `.bak-*` backup suffix absorb any extension), which is why the tree is76 walked. Over 1.5 s or 200,000 entries, character classes and escapes fail77 closed.78- **Commandless reads.** `$(< file)` substitutes the file's content and zsh79 pages a bare `< file`, so `echo $(< .env)`, `cat <<< $(< .mcp.json)` and80 `< ~/.claude.json` are judged like `cat`. Output-only redirects81 (`> out.txt`) stay allowed.82- **Anything over 32 KiB.** A command too large for the policy parser is83 refused whatever it names (split it, or pass long content by file path);84 git-guardian refuses those too.85- **A recursive search into a secret folder** (`grep -r`, `rg`, content-mode86 Grep) that prints lines, including a symlink into that folder. Content-mode87 Grep over a directory enumerates with `rg --files --hidden --no-follow`,88 excludes `.git`, `.svn`, `.hg`, `.bzr`, `.jj` and `.sl`, and uses Claude's89 whitespace/comma glob splitting (brace alternations stay together) and type.90 Any listed candidate refuses the search regardless of the content pattern.91 Resolution tries PATH, Claude's embedded rg (`CLAUDE_CODE_EXECPATH` with92 argv0 `rg`), Homebrew locations, then vendored rg under Claude's install.93 Without rg, a bounded Python superset walk includes hidden and gitignored94 files, ignores glob/type filters, prunes those six VCS dirs and skips links.95 Clean trees allow on either path. Enumeration fails closed after 2 seconds,96 40,000 entries or 2 MiB of names, or on a tool error. Brace/class and97 specimen pre-checks apply only when the path is not a directory.98- **A secret helper:** running `claude-proxy-token` (the `apiKeyHelper`).99- **The keychain:** `security find-generic-password` / `find-internet-password`100 with `-w` or `-g`, and `security dump-keychain`.101- **Environment dumps, in any form or pipeline, no exceptions:** `env` with no102 command (`env -0` too), `printenv` (any argument), `export` bare or `-p`,103 bare `set`, `declare`/`typeset` bare or with `-p`/`-x`, `compgen -e`;104 `echo`/`printf`/`launchctl getenv` of a secret-named variable; `ps -E`,105 `ps e`, `ps eww`; `launchctl print|export|procinfo`; `/proc/*/environ`.106 `env NAME=value cmd` (env as a wrapper) still runs. Variable names only?107 Use a script file.108- **Inline interpreter code that touches the environment at all.** For109 python, node, ruby, perl, php, deno, bun, osascript and the rest: inline110 code in any spelling (`-c`/`-e`, clustered `-Ic`/`-sc`, attached `-cCODE`,111 `--eval=CODE`, `-p`, `-r`, `deno eval`, `-`, a heredoc or here-string with112 no script file) is refused if it references `os.environ`, `environ`,113 `getenv`, `process.env`, `ENV`, `%ENV`, `Deno.env`, `Bun.env`, AppleScript114 `system attribute` / `do shell script`, Swift `ProcessInfo`/`.environment`,115 Scala `sys.env`, or Tcl `$env(`, `env(`,116 `array get env`, `parray env`. The same goes for awk-family `ENVIRON` and117 jq/yq `env`, `$ENV`, `strenv` (a `.env` field is fine). Code piped on stdin118 into any interpreter or shell (`echo 'puts $env(K)' | tclsh`,119 `echo printenv | sh`, `cat <<EOF | node`) is inline code too; a variable in120 it means the code only exists at run time, so it is refused. Output of121 another command piped in (`cat tool.py | python3`) counts as a script file.122 A heredoc or here-string fed to any shell, `eval`'s arguments and123 `source /dev/stdin <<EOF` are judged as shell text; `source <(...)` is124 refused. `busybox`/`toybox <applet>` is judged as the applet.125 No name matching: aliases (`e=os.environ; print(e)`) leave nothing to match. It is126 also refused if it names a listed path, opens a listed name127 (`open('.env')`) or runs the helper. Code that needs a key belongs in a128 script file; `( set -a; . x.env; set +a; python3 tool.py )` keeps working.129130## The masked reader131132```bash133python3 ~/.claude/hooks/secret-read-guard/scripts/masked-read.py <file>134```135136Exactly that argv: `python3 <reader> <files>`. Any interpreter option137(`-I`, `-X`, `-c`, `-m`, `-W`...) or other shape, direct execution included,138is not exempt. It prints the file's structure with every value replaced by139`<redacted len=N sha=xxxxxxxx>` (JSON, YAML, env and TOML aware; unknown140formats print key names only; comments are dropped). Equal values share a141sha, so two files can be compared without showing either.142143MCP configs stay auditable: inside any JSON `mcpServers` object, server144names and plain fields (`command`, `args`, `type`, `url`, `cwd`, numbers)145print as they are, while everything under `env` and `headers`, any field146whose key names a credential (token, secret, password, api key, auth,147cookie...), the whole argv element after a credential-named flag in `args`148(even one starting with `-`), the whole value of a credential-named149`name=value` / `Name: value` element (spaces included), URL passwords,150query values whose percent-decoded name names a credential (`api%5Fkey`),151explicit `Bearer`/`Basic`/`Token` values at any length, and strings with a152credential shape (`sk-`, `ghp_`, `sbp_`, `xox*-`, `AKIA`, JWTs, long random153tokens) are redacted. Once inside `env`, `headers` or a credential-named key,154every descendant is redacted; a `mcpServers` nested there never becomes155readable. A `.claude.json` prints only its non-empty `mcpServers` objects,156keyed by path (`projects > /repo > mcpServers`); its other keys hold157history and account data.158159```bash160python3 ~/.claude/hooks/secret-read-guard/scripts/masked-read.py --ps [filter...]161```162163prints `pid ppid command` for every process, with the same credential shapes164redacted in each command line. A flattened command line has lost its argv165boundaries, so from the first credential marker on (a dash-flag naming a166credential, `NAME=` / `Name:` naming one, or `Bearer`/`Basic`) the rest of167the line is redacted whole: a dash-leading, quoted or spaced value can't be168told apart from the next argument. Filters are case-insensitive substrings169matched against the redacted line, so a filter can't probe a hidden value.170Shapes are a heuristic: a key with no recognizable shape, passed positionally171after a flag whose name doesn't say credential, still prints. Prefer the pid172and name forms when they answer the question.173174The guard exempts exactly this file (by real path), not a look-alike. The refusal message names175the reader's path.176177## Allowed178179`ls`, `stat`, `test -f`, `wc -c`, `shasum`, `chmod`, `grep -c`, `jq 'keys'`,180`. file.env` / `source` with a script or binary after it (the sanctioned way181to use a key), `env NAME=value cmd`,182`cp x.env x.env.bak-<date>`, reading `.env.example`, `jq '.mcpServers | keys'183.mcp.json`, `pgrep -x`/`-f`/`-l` (without `-f` and `-l` together, and without184`-a`), `ps -axo pid,ppid,stat,etime,comm`, and every command that names no185listed file.186187## Known limits188189**This guard is a speed bump plus an audit trail, not a sandbox.** It parses190shell text and cannot enumerate every interpreter, applet, encoding or191indirection an agent could use to read a file or the environment. The primary192control is keeping secrets out of agent-readable files: the keyout lane's193`apiKeyHelper` plus the macOS keychain. Treat a refusal as a nudge toward the194masked reader or a script file, and a pass as "no known shape matched", never195as proof that nothing leaked.196197Specific gaps known today:198199- Other process viewers that print command lines (`pstree`, `htop`,200 `procs`, `sysctl kern.procargs2`) are not parsed; `ps` and `pgrep` cover201 the shapes seen in transcripts. The `ps` parser judges macOS and procps202 spellings and fails closed on run-time input, but an exotic option spelling203 it misreads can still pass. It also over-refuses a few harmless forms204 (`ps -axo pid,comm -X`, `ps -axo pid,args -c`); use a plain `-o` list.205- The find walk sees the tree as it is when the hook runs; a file created206 between the check and the run is not seen (the same race content Grep207 has). A start folder too big to walk inside the bound is refused; name a208 narrower folder.209210- Interpreter **scripts** (`python3 tool.py`) are not read; only their operands211 and inline code are checked. Languages with only file runners (`go run`)212 are the same.213- Shell text is judged with bash meanings: fish's `set -x` / `set --show`214 list exported variables there, but `set -x` is tracing in bash, so it is215 not refused. Paths built at run time in code216 (`os.path.join(home, ".codex", "auth.json")`) are out of reach.217- `source x.env && echo "$VAR"` is caught only when the variable name looks218 secret (`token`, `secret`, `password`, `api_key`, `credential`...).219- Bash recursive searches inside ordinary repos are not walked; `rg` skips220 hidden files by default, `grep -r` does not. Directory content-Grep now221 checks hidden candidates with Claude's rg flags and retains rg's ignore222 rules. Without rg the superset walk may deny a glob/type-filtered search223 because it also checks ignored or excluded files. Repos over the enumeration224 cap refuse content Grep; use a narrower path. Filesystem changes between225 the check and the actual search remain a TOCTOU race.226- Editing a listed file needs a path that never prints it: Claude's Edit tool227 needs a Read first (refused), and inline code that opens the file is228 refused. Use a script file or the tool that owns the file.229- These limits are why the keyout lane also takes secrets out of readable230 files. This guard narrows the accident; it is not a sandbox.231232## Measured233234Replaying distinct real Bash commands from local Claude transcripts (scratch235HOME, no real file read): round 0, 369 of 25,702 refused (1.44%); round 1236(stricter env, sed and inline-code rules), 379 of 24,904 (1.52%); round 2237(final class rules: any env reference in inline code, no env-dump238exceptions), 431 of 24,892 (1.73%); round 3 (awk/jq/AppleScript/Tcl env239reads, piped stdin code), 432 of 24,880 (1.74%). About 60% of refusals name a file only at240run time; most of the rest touch a listed file or the environment. Hook median24181 ms.242243## Wiring244245Claude: PreToolUse on `Bash|Monitor|Read|Grep`, fail-closed launcher.246Codex 0.171: native `PreToolUse` hook on `^Bash$` through247`scripts/hooks/codex-policy-hook.py` (Codex has no Read tool; shell is its248read path). Codex runs a new hook only after the owner trusts it from plain249`codex` via `/hooks`. Each denial appends `ts`, `input_sha256` and `rule` to250`~/.claude/logs/secret-read-guard-ledger.jsonl` (override:251`SECRET_READ_GUARD_LEDGER`), never the command text.