Skip to content

head-check: make the required check impossible for a pull request to rewrite (base-pinned job + GitHub App) #34

Open

Description

@scuttletoby

The problem

The head-check action (fork-ci/actions/head-check, PR #33) is meant to be a required check: a pull request may only merge when its head is the change the reviewers read.

But it runs on pull_request, and a pull_request run uses the workflow files of the pull request itself. So anyone who can push a branch can change the job, or add another job with the same name that always passes. Then the required check is green without anyone having read the change.

GitHub's ruleset rule "Require workflows to pass" would stop this, but it is only for organizations on paid plans. Repositories owned by a user account (this fork, and the projects that use it) cannot use it.

Today the README says this plainly, and the stopgap is: a person reads every pull request that changes .github/workflows/ or the action's files.

Proposed fix (future work)

  1. A pull_request_target job that runs the check from code pinned on the base branch, never the pull request's own code. It reads the pull request only as data (no checkout of PR code that runs).
  2. The job posts its result (a commit status or check run) through a separate GitHub App. The App's private key lives in a GitHub environment that only the base branch may use, so a pull request's workflow cannot read it.
  3. The branch ruleset's required check is bound to that App as its only allowed source, so a job in a pull request that uses the same name does not count.

Questions to settle first

  • Where the App runs its token exchange (an action step with the key from the environment is enough; no server needed).
  • How the queue (pr-queue) re-runs it after a lens comment is posted (pull_request_target has no comment trigger; issue_comment or a re-run from the ready command).
  • Whether this stays general: the App and its environment are project setup; the workflow is a reusable one in this fork.

Found by the security lens on PR #33.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions