Skip to content

Hook: other GitHub API routes to main (main session), and programs that can write a logbook table (pre-existing, high) #99

Closed

Description

@erickb336

Found in the sage's repo pass (T206, run R712). Two pre-existing high gaps, on both ea9f728 and 6ea307f. Size: small each; risk: auth (2 clean review cycles). They can be one PR or two.

The sage's own hook refuses to write some literal command text into a file, so a few examples are in words. Build the literal forms in the tests.

1. The main session can change main through other GitHub API routes (high, main session only)

packages/sage-core/push-policy.mjs (about lines 29, 93 and 95) refuses only one GitHub API form that names the main branch. These pass for the main session today (agents are refused since #86):

  • gh api with the PATCH method on the refs endpoint of heads/main, with a sha field and force set to true;
  • gh api with the PUT method on the contents endpoint of a file, with the branch field set to main;
  • gh api graphql with a query that calls the updateRefs mutation.
    Work reaches main only through a pull request. Refuse every gh api call that writes (any method other than GET, or graphql with a mutation) when it names the main or master branch, the refs of heads/main, or a ref update mutation, for the main session too.

2. Programs that can write a logbook file are missing from the write list (high)

packages/sage-claude/hooks/sage-hook.mjs (the WRITE_NAMES list at about line 621 and writesIn at about line 686) does not know these, so each can write a logbook table, for an agent and for the main session:

  • curl with the -o option to a logbook table;
  • the version-control program's diff or show subcommand with the --output= option to a logbook table;
  • ditto, and scp, with a logbook table as the target.
    Add them, and look for other common programs with an output-file option (for example wget -O, tar -C with x, unzip -d, rsync, install, dd of=, openssl -out, sqlite3 with .output), so that the list covers the usual forms. The hook's comment says the sandbox is the full guard for shell writes; say in the PR whether the sandbox blocks these paths today.

Acceptance

  • Each example is refused with a test, for the roles the example names. Ordinary commands still pass (for example curl to a scratch file, and gh api GET calls).
  • 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 API-policy part now has its own task, #197, and draft PR #198. It changes shared core and both generated bundles without editing the Claude hook or PR #140 files.

    Review found additional forms that need refusal, including opaque GraphQL branch IDs and ambiguous endpoint expansion. These repairs and the required review cycles are still in progress. The PR is not ready to merge.

    The logbook-writer part of this issue remains open and untouched because it overlaps Claude's active hook work.

  3. erickb336 commented on Oct 13, 2026

    @erickb336
    OwnerAuthor

    The shared API-policy part is merged in PR #198 at 29af916. Component issue #197 is closed.

    Reviewed head ed4cb8f passed two clean code, security, and QA cycles. Build and check passed. All 1,158 local tests and all 1,158 exact-head CI tests passed. The new regression test fails on detached main because a protected PATCH receives no refusal. Attack strings reached only the parser and hook handler; no live API write ran.

    This adds protected-branch API checks to shared core and both generated plugins. No Claude hook source or PR #140 files changed. The logbook-writer part of #99 remains open. This does not enable installed automatic Sage in Codex.

  4. erickb336 commented on Oct 13, 2026

    @erickb336
    OwnerAuthor

    PR #204 is merged. The shared core now classifies common output-file programs, including curl output forms, Git diff/show/log output, OpenSSL output, ditto, scp, wget, and sqlite3. Tests cover both provider bundles and protected versus scratch targets. Two clean code/security/QA cycles, 1,171 local/CI tests, and 1,293 integration tests passed.

    This completes the shared Codex component tracked in #203. The active Claude hook's writer list remains unchanged while #140 is open, so #99 stays open. No sandbox protection or installed automatic Sage activation was verified by these parser tests.

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