Skip to content

Read an Inherited GH_REPO From the Session Environment in the Write Guard #3147

Closed

Description

@ptr727

Context

Raised by Copilot on the develop -> main promotion #3146, against the GH_REPO reading #3135 added. The gap is older than that reading: main's guard reads no GH_REPO at all, so it allows the same commands. Confirmed with classify probes on constructed commands, origin example/repo, run under both guards with GH_REPO=stranger/example set in the hook process's own environment:

main=allow dev=allow | gh pr comment 5 --body hi
main=allow dev=allow | gh issue create --title t --body b
main=allow dev=deny  | GH_REPO=stranger/example gh pr comment 5 --body hi

Gap

_gh_repo_assignments reads GH_REPO only from the command text, from a prefix or an earlier export. A session whose own environment already holds GH_REPO passes it to every gh call the Bash tool runs, so gh pr comment 5 --body hi writes to the repository that value names while the guard reads no target and compares the checkout's origin instead.

Possible Direction

Read GH_REPO from the hook's environment, through the environ seam classify already takes, as the value reaching a gh word where the command text sets none and no repo flag names one. A command-text assignment or a repo flag still overrides it, as gh reads it. Confirm first that the hook process inherits the environment the Bash tool's commands run in.

Activity

  1. added
    pre-existingReview finding classed pre-existing per local-strict-review Disposing of Findings
    scriptA defect in hub tooling
    on Oct 16, 2026
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

    pre-existingReview finding classed pre-existing per local-strict-review Disposing of FindingsscriptA defect in hub tooling

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions