Skip to content

gate: check the job token reads the Environment over GraphQL #92

Closed

Description

@scuttletoby

Follow-up from the #85 security quick check (#85 (comment), note n2).

The gate's guard falls back to GraphQL when the REST read of the Environment hits a rate limit or a 5xx. GitHub's docs do not say which permission the job's GITHUB_TOKEN needs to read a repository Environment over GraphQL. The gate job grants contents, pull-requests and actions read, not deployments.

If the token cannot read it, the fallback never fires and the gate behaves like plain "post nothing when the Environment cannot be read" (still safe, but the comment-spam case posts nothing more often).

To do: in a scratch repository, run the gate workflow with its declared permissions and query repository.environment(name:) over GraphQL. Record yes/no. If no, either add deployments: read (check it gives nothing else) or remove the fallback and its README text.

🤖 Generated with Claude Code

Activity

  1. added
    enhancement
    on Nov 14, 2026
  2. added a commit that references this issue on Nov 21, 2026
  3. scuttletoby commented on Nov 21, 2026

    @scuttletoby
    OwnerAuthor

    Answer: yes. The job's GITHUB_TOKEN with exactly the gate job's declared permissions (contents: read, pull-requests: read, actions: read; no deployments) reads a repository Environment over GraphQL. deployments: read is not needed.

    How: a temporary workflow on a scratch branch of this repository (triggered only by push to that branch, job permissions copied from the gate job, no environment: key) ran the guard's own query, repository(owner, name) { environment(name:) { name } }, with gh api graphql and the job token. It printed only the result shape. The gate's Environment head-gate does not exist in this repository, so the step also asked for fork-push, an Environment that does exist. Without that second name, a missing Environment would look the same as one the token may not read.

    run permissions head-gate fork-push
    44903044898 contents, pull-requests, actions: read null, NOT_FOUND "Could not resolve to an Environment with the name head-gate.", exit 1 {"name":"fork-push"}, exit 0
    44903083393 the same + deployments: read the same the same

    The "Set up job" log of the first run lists the token's permissions as Actions, Contents, Metadata, PullRequests: read. So the GraphQL fallback in the guard can fire with the permissions as declared. A missing Environment still gives NOT_FOUND, which the guard reads as "not seen" (False). The scratch branch is deleted.

    Follow-up: a README-only PR that records this result.

    🤖 Generated with Claude Code

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions