Skip to content

Reject brace and glob command words before Git checks (T199) - #73

Merged
erickb336 merged 1 commit into
mainfrom
codex/t199-brace-glob
Oct 7, 2026
Merged

erickb336 merged 1 commit into
mainfrom
codex/t199-brace-glob

Conversation

@erickb336

@erickb336 erickb336 commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

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.mjs and its tests. npm run build regenerated the Claude plugin hook.

Validation

Fake ps, pgrep, and kill were first on PATH for every test run. The PATH prefixes below use equivalent relative paths to keep private machine paths out of this PR.

Command Last result
npm run build built 102 files
npm run check ✓ all checks pass (1 timing bound carries "// timing-ok:")
git diff --check Exit 0
Focused command below tests 6; pass 6; fail 0
PATH="$PWD/../test-bin:$PATH" npm test tests 465; pass 465; fail 0

Focused command:

PATH="$PWD/../test-bin:$PATH" node --test --test-name-pattern='^T199:|^a merge passes only|^programsRun:' scripts/sage-hook.test.mjs

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:

  1. Create a detached worktree: git worktree add --detach ../sage-t199-proof origin/main.
  2. Copy only the final test file: cp scripts/sage-hook.test.mjs ../sage-t199-proof/scripts/sage-hook.test.mjs.
  3. In that worktree, run PATH="$PWD/../test-bin:$PATH" node --test --test-name-pattern='^T199:' scripts/sage-hook.test.mjs.
  4. Result: 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.

@erickb336
erickb336 merged commit ea9f728 into main Oct 7, 2026
1 check passed
@erickb336
erickb336 deleted the codex/t199-brace-glob branch October 7, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T199: Hook refuses brace and glob words in gh and git before the merge and push tests

1 participant