Skip to content

Hook: program names without case, PowerShell Start-Process and a quoting trick reach the upload and stash rules (pre-existing, high) #97

Closed

Description

@erickb336

Found in the sage's repo pass (T206, run R712). Size: small. Risk: auth (2 clean review cycles). High, pre-existing on both ea9f728 and 6ea307f; not added by PRs 78 to 87, which closed other gaps.

The sage treats these as ordinary command forms, not deliberate hiding, so owner rule G83 does not make them sandbox work. The sage's own hook refuses to write the literal commands into a file, so this issue describes them in words: "VCS" means the version-control program that the hook's upload rule checks, and "upload" means its subcommand that sends a branch to the remote. Build the literal forms in the tests.

1. The program name is compared with case (high)

packages/sage-core/push-policy.mjs (about line 28) matches only the lower-case VCS name, and packages/sage-claude/hooks/sage-hook.mjs (about line 1057) checks for that exact name. On macOS the file system ignores case, so the VCS name in capital letters runs the VCS. These pass today:

  • the VCS name in capitals with the upload subcommand to the remote's main branch (main session);
  • the same with the force flag to a task branch (main session);
  • the VCS name in capitals with the stash subcommand, also by its full Homebrew path (agent);
  • in PowerShell: the VCS name with one capital letter, and with the .exe ending, uploading to main.

Compare program names without case and without a trailing .exe, for the VCS, gh and every name the rules check (stash, the process tools, the readers and the writers).

2. PowerShell Start-Process (high)

Start-Process with the VCS program and an argument list of upload, origin and main passes for the main session and for agents; with the force flag in the list too; and with an argument list of stash it passes for an agent. The rule reads the joined argument list as one subcommand word. Read Start-Process (and its alias start, with FilePath and ArgumentList in any order) as a run of its program with those arguments.

3. A PowerShell quoting trick (medium)

In PowerShell a backslash does not escape a double quote. So an echo of a quoted backslash, a semicolon, an upload to main, a semicolon, and another echo of a quoted backslash runs three commands in PowerShell, while the hook reads it, as bash would, as one harmless echo. The same shape around the pull-request completion command with the admin flag passes for the main session. Read PowerShell text with PowerShell's quoting, or refuse a PowerShell command that holds a backslash before a double quote together with the VCS or gh.

Acceptance

  • Each example above is refused with a test, for an agent and for the main session where the example says so. Ordinary lower-case commands still pass.
  • The new tests fail on main and pass on the branch. npm run build, npm run check and npm test pass with fake ps, pgrep and kill first on PATH.

Activity

  1. added
    codex
    on Oct 11, 2026
  2. erickb336 commented on Oct 13, 2026

    @erickb336
    OwnerAuthor

    The independent shared-policy part is tracked in #199 and draft PR #200. It normalizes executable spelling for push/API recognition and expanded Git/GitHub CLI subcommands. No Claude hook source or PR #140 files change.

    The Claude agent-specific checks, other reader/writer checks, and PowerShell forms remain in this issue. This PR does not close #97 or enable installed automatic Sage.

  3. erickb336 commented on Oct 13, 2026

    @erickb336
    OwnerAuthor

    The shared executable-name part is merged in #200 at 7e80bad. Component #199 is closed.

    Reviewed head 26b89da passed two clean code, security, and QA cycles; build/check; all 1,160 local tests; and all 1,160 exact-head CI tests. Both new tests fail behaviorally on detached main. No attack command ran against Git, GitHub, or a real shell.

    The integration is pushed at add48e9. Build/check and six focused checks pass; the complete integration suite is running. This does not close #97: Claude's agent-specific checks, other executable checks, and PowerShell forms remain open. No PR #140 files changed.

  4. erickb336 commented on Oct 13, 2026

    @erickb336
    OwnerAuthor

    PR #206 is merged and #205 is closed. Shared writer and reader checks now use the existing executable-name normalizer, including mixed case and .exe. Reader options keep their original case and values. Printed path text stays data; real protected redirections remain refused.

    The change passed two clean code/security/QA cycles, 1,174 local and exact-head CI tests, and the integration branch passed 1,296 tests at 9c0a171. New tests fail behaviorally on detached main. All owned local checks and reviews finished.

    This completes the shared-classifier component only. The active Claude hook, process-tool comparisons there, and PowerShell forms remain outside this change, so #97 stays open. Automatic Sage remains disabled; no installed runtime or real-model pilot was verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    codex

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions