Repository navigation
Reject brace and glob command words before Git checks (T199) - #73
Merged
Merged
Conversation
This was referenced Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #57
Sage task T199
Brace and glob words could hide a push or merge command from the hook. The hook now refuses those forms in program words and Git/GitHub subcommand words before it checks pushes, merges, or first uploads.
The check also refuses expansion text piped into a shell, including pipes through filters. Known heredoc scripts keep the existing recursive parser. Ordinary argument braces/globs and literal shell tests remain allowed.
This change edits
packages/sage-claude/hooks/sage-hook.mjsand its tests.npm run buildregenerated the Claude plugin hook.Validation
Fake
ps,pgrep, andkillwere first on PATH for every test run. The PATH prefixes below use equivalent relative paths to keep private machine paths out of this PR.npm run buildbuilt 102 filesnpm run check✓ all checks pass (1 timing bound carries "// timing-ok:")git diff --checktests 6; pass 6; fail 0PATH="$PWD/../test-bin:$PATH" npm testtests 465; pass 465; fail 0Focused command:
The four new tests cover 23 attack inputs and 14 ordinary controls across Bash/Monitor and main/agent identities. Each final test fails on main
95bf953e015c0329bc7e41c8616d32b5b8775538:git worktree add --detach ../sage-t199-proof origin/main.cp scripts/sage-hook.test.mjs ../sage-t199-proof/scripts/sage-hook.test.mjs.PATH="$PWD/../test-bin:$PATH" node --test --test-name-pattern='^T199:' scripts/sage-hook.test.mjs.tests 4; pass 0; fail 4. Main allows the obscured commands that these tests require it to refuse.An independent security reviewer checked the final diff and ran 52 additional direct hook checks. All passed, with no actionable findings remaining. The checks cover piped attacks, literal shell tests, harmless filter text, and heredoc behavior.
GitHub CI passes on
36f5dd6c1d932c90bba31640b15ea0797d05f02b.Not verified
Attack strings went only to the hook as JSON input. No attack string ran through a real shell. Native shell behavior and a live Claude session were not tested. Sage's required two clean review cycles remain pending.