Skip to content

Pin the GitHub Host in the Hub Scripts So GH_HOST Cannot Move Their Reads and Writes #4489

Done

Description

@ptr727

Most of the hub's gh calls name no host, so they follow GH_HOST when it is set. The registry names every repository on github.com, so an audit, a review-loop read, or a merge run with GH_HOST pointing at another host reads or writes that other host instead. spec/audit_environments.py (from #4480) is the one site that pins --hostname github.com, with the reason written beside it.

Failure

With GH_HOST=other.example exported, spec/audit.py's gh() sends gh api repos/ptr727/<repo> to other.example. The audit then reports drift, or a 404, from a host the registry never named, while its environment checks in the same run stay on github.com.

Sites

Each counts list-form "gh", ... calls that carry no --hostname:

  • spec/audit.py gh() (1)
  • spec/resolve_secrets.py (4), read_live_names among them
  • scripts/pr_review.py (3)
  • scripts/agent_policy.py (2)
  • scripts/backlog_metrics.py, scripts/gh_graphql.py, scripts/handoff.py, scripts/pr_merge.py (1 each)

The shell and PowerShell scripts have not been swept.

Fix

Pin the host once per entry point rather than per call, for example a shared helper that sets --hostname github.com for gh api and GH_HOST=github.com in the child environment for the other subcommands. Add a test that runs a site with GH_HOST set to a constructed host and asserts the call still targets github.com. Whether every site warrants it is a Trust Boundaries and Hardening Effort judgment. The audit and the review-loop writes are the ones that act on what they read.

Origin

Raised by the local strict review on #4480 against unchanged code, and listed there under Pre-existing findings, not filed. Filed under pr-review-conduct outcome 4, since it is a correctness defect with a stated failure.

Activity

  1. added
    pre-existing
    script
    on Nov 26, 2026
  2. ptr727 commented on Nov 26, 2026

    @ptr727
    OwnerAuthor

    Another site of this class, raised by the frontier local strict review over promotion #4485, where it holds the merge gate: spec/audit_environments.py names() (line 27, from #4480) duplicates read_live_names at spec/resolve_secrets.py:207, and only the first one pins the host. A fix here should give both callers one host-pinned reader, rather than pinning the second copy.

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-existingscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions