Skip to content

fix: restrict BEGIN_COMMIT_OVERRIDE to PR authors with write access#2781

Open
evilgensec wants to merge 1 commit into
googleapis:mainfrom
evilgensec:fix-commit-override-trust
Open

fix: restrict BEGIN_COMMIT_OVERRIDE to PR authors with write access#2781
evilgensec wants to merge 1 commit into
googleapis:mainfrom
evilgensec:fix-commit-override-trust

Conversation

@evilgensec
Copy link
Copy Markdown

Summary

BEGIN_COMMIT_OVERRIDE in a merged PR's body lets the body's text replace the merge commit message that drives release notes, version bumps, and CHANGELOG generation. The PR body is fetched live at release-please run time (src/github.ts GraphQL query on pullRequest.body), and GitHub keeps the PR body editable by its author indefinitely after merge. An external contributor whose otherwise innocuous PR has been merged can later rewrite their PR body to insert a forged commit message — for example, BEGIN_COMMIT_OVERRIDE\nfeat!: x\n\nBREAKING CHANGE: <phishing markdown>\nEND_COMMIT_OVERRIDE — and that text drives the next CHANGELOG entry, forces a major version bump, and ends up in the published GitHub Release notes without any maintainer review.

This PR gates the override on the PR's authorAssociation (already exposed by the GitHub GraphQL PullRequest type) and honors it only for OWNER, MEMBER, and COLLABORATOR — the roles that already have write access to the repository. PRs from CONTRIBUTOR / FIRST_TIME_CONTRIBUTOR / NONE fall back to the merge commit message, matching the pre-BEGIN_COMMIT_OVERRIDE behavior.

#1161 added BEGIN_COMMIT_OVERRIDE for the maintainer "retroactively fix a release note" workflow; the README still describes it that way. The check here keeps the original maintainer workflow intact (maintainers are OWNER/MEMBER/COLLABORATOR) while closing the path that lets non-maintainer authors abuse it.

Changes

  • src/pull-request.ts: add PullRequestAuthorAssociation type and optional authorAssociation field on PullRequest.
  • src/github.ts: request authorAssociation in the mergeCommitsGraphQL query and thread it onto commit.pullRequest.
  • src/commit.ts: in preprocessCommitMessage, ignore BEGIN_COMMIT_OVERRIDE unless authorAssociation is OWNER, MEMBER, or COLLABORATOR.
  • test/commits.ts: existing override tests now set authorAssociation to a trusted value; two new tests cover (a) CONTRIBUTOR override is ignored and (b) missing authorAssociation is treated as untrusted.
  • test/manifest.ts: existing manifest-mode override fixture sets authorAssociation: 'MEMBER'.

Test plan

  • npm run lint — no new warnings or errors.
  • npm test — 1101 passing, 0 failing.
  • New tests cover both the trust path (MEMBER/OWNER still honored) and the deny paths (CONTRIBUTOR and missing authorAssociation fall back to the commit message).

The BEGIN_COMMIT_OVERRIDE section of a merged pull request's body is read
live from GitHub at release-please run time (via the GraphQL `body`
field). GitHub keeps the PR body editable by its author indefinitely
after merge, so an external contributor whose otherwise innocuous PR has
been merged can later rewrite the body to insert a forged commit message
that drives the next CHANGELOG, version bump, and GitHub release notes
without any maintainer review.

Gate the override on the PR's `authorAssociation` and honor it only for
OWNER, MEMBER, and COLLABORATOR — the roles that already have write
access to the repository. PRs from CONTRIBUTOR / FIRST_TIME_CONTRIBUTOR /
NONE fall back to the merge commit message.
@evilgensec evilgensec requested review from a team as code owners May 21, 2026 01:27
@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants