From 3c7542881082ded2a540aae3c37624733b4c5cae Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 05:21:05 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20count=20a=20bot-login=20a?= =?UTF-8?q?uthor=20as=20the=20hive's=20commit=20only=20when=20GitHub=20ver?= =?UTF-8?q?ified=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/security-15421.md | 1 + src/docs/operator-reference.md | 2 +- src/pkg/github/pr_merge_state.go | 20 +++++++++++++++---- .../pr_merge_state_commit_by_hive_test.go | 12 +++++++++-- 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 changelog.d/security-15421.md diff --git a/changelog.d/security-15421.md b/changelog.d/security-15421.md new file mode 100644 index 0000000000..33a9a60eb2 --- /dev/null +++ b/changelog.d/security-15421.md @@ -0,0 +1 @@ +- A rebase-then-merge follow-through no longer treats an unsigned head as the hive's own just because its author email is the App bot's noreply address: an author GitHub resolves to the App bot now counts only on a commit GitHub reports as verified, as GitHub's update-branch commits are ([#15421](https://github.com/hivecommons/hive/issues/15421)). diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 88ae7351d3..3f49e01e9f 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -479,7 +479,7 @@ verified owner or an authorized user with the `merger` role: | Decision | What it does | Audit / ledger | |---|---|---| | `merge-now` — *Merge now as maintainer* (secondary; *Approve and let hive merge* leads) | Comments on the PR that @you merged it from the dashboard, then merges it at once through the hive's GitHub App (`MergePRVia`, audit path `dashboard`). Refused when the PR is merged or closed, or when you are its author. | `repo_item_decision_merge`; `last_operator_action.action: merge-now`; toast *merged*. | -| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it — update-branch under the App (author resolved to the App bot) or a committer GitHub resolves to the App bot; a committer matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as *verified*, and the author counts only when GitHub resolves it to the App bot ([#15182](https://github.com/hivecommons/hive/issues/15182)). **Operational prerequisite:** the fixer's own rebase of a contributor PR is a plain unsigned git commit (the push broker sets `commit.gpgsign=false`, and the signed-commit reconciler only re-signs PRs the App bot authored), so on a `dirty` contributor PR the follow-through settles `failed` (`foreign-head`) unless the fixer host signs its pushes with a key GitHub verifies against a pane-domain address; *Approve the new head & merge* on the fixer's head is the way out until then. A head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | +| `merge-now` on a PR whose `mergeable_state` is `dirty` or `behind` — *Rebase, then merge as maintainer* | Never a GitHub 405. Records your approval first (/lgtm + /approve naming you), arms a rebase-then-merge follow-through (`/data/rebase-merge-followups.json`), kicks the rebase (update-branch on the hive's own PR when only behind; otherwise the fixer lane, which owns a parked PR with an armed follow-through), and answers `202 rebase-queued`. A 2-minute ticker then reads the PR: `mergeable_state: clean` on the rebased head → merges it with your approval attributed; still `dirty` after 2 h, CI red, or no rebase within the deadline → `failed` with the conflicting files and the options *Adopt into fresh branch* / *Close as superseded* (also left as a note on the PR). Refused on a fork whose author has not allowed maintainer edits (`head-not-pushable`). The approval is bound to the head you read: a new head on a contributor's PR counts as the rebase only when GitHub says the hive committed it — update-branch under the App (author resolved to the App bot on a commit GitHub reports as *verified*) or a committer GitHub resolves to the App bot; a committer matched by the pane identity email domain alone, with no GitHub login resolved, also needs GitHub to report the commit as *verified*, and the author counts only when GitHub resolves it to the App bot and reports the commit as *verified* — GitHub derives the author login from a free-text email anyone can set ([#15182](https://github.com/hivecommons/hive/issues/15182), [#15421](https://github.com/hivecommons/hive/issues/15421)). **Operational prerequisite:** the fixer's own rebase of a contributor PR is a plain unsigned git commit (the push broker sets `commit.gpgsign=false`, and the signed-commit reconciler only re-signs PRs the App bot authored), so on a `dirty` contributor PR the follow-through settles `failed` (`foreign-head`) unless the fixer host signs its pushes with a key GitHub verifies against a pane-domain address; *Approve the new head & merge* on the fixer's head is the way out until then. A head anyone else pushes after your click settles the follow-through as `failed` (`foreign-head`) with nothing merged, a note on the PR, and *Approve the new head & merge* / *Close as superseded* as the ways out. | `repo_item_decision_merge` with `status: rebase-queued`; `last_operator_action.action: merge-now`, outcome `pending` → `applied` / `failed`, `followed[]` steps `approval-recorded`, `rebase-kicked`, `rebased`, `ci-green`, `merged` / `failed`; row `rebase_merge.state`; toast *rebase queued, merge to follow*. | | `queue-merge` — *Approve and let hive merge* (lead) | Admits the head (`admitted_by: operator-approval:`), leaves an `APPROVED` review in your name with a note, adds the automerge label, and leaves the merge to the hive's auto-merge sweep, which merges through its own App on the next tick once CI is green and the head has soaked. On an untrusted author's PR that admission is the one thing that lets the trusted-author lane merge it: the lane's `untrusted-author-role` skip yields to the recorded approval for that exact head, and the merge comment names you (*merged by Hive on behalf of @you …*). Refused on your own PR. | `repo_item_decision_queue_merge`; `last_operator_action.action: queue-merge`; toast *approved — hive will merge on the next tick once CI is green*. | **Approve is the trust override for that head diff --git a/src/pkg/github/pr_merge_state.go b/src/pkg/github/pr_merge_state.go index 08d3b5fcab..324d502295 100644 --- a/src/pkg/github/pr_merge_state.go +++ b/src/pkg/github/pr_merge_state.go @@ -112,11 +112,18 @@ func (c *Client) GetPRMergeState(ctx context.Context, repo string, number int) ( // CommitByHive reports whether the commit at sha is the hive's own work: // its committer resolves to the App bot (by login or noreply address) or to // an address in the pane identity domain, or its author resolves by login -// to the App bot, as on GitHub's update-branch under the App. When GitHub +// to the App bot on a commit GitHub verified, as on GitHub's update-branch +// under the App (web-flow commits and signs it). When GitHub // resolves no login for the committer, the email-only match also requires // the commit's signature to be verified by GitHub, which binds the signing // key to the committer address only (hivecommons/hive#15182); the author is // free text GitHub never vouches for, so no email-only author match counts. +// GitHub resolves the author login from that same free-text email, so a +// pusher setting the App's noreply address gets the bot login on an +// unsigned commit; the author login therefore counts only on a verified +// commit. A web-flow committer login is no proof either (it too resolves +// from an email anyone can set), while update-branch commits are always +// verified (hivecommons/hive#15421). // The fixer's plain-git rebase of a contributor PR is an unsigned, // email-only pane committer (the push broker sets commit.gpgsign=false and // the signed reconcile pass only walks App-authored PRs), so it does not @@ -146,9 +153,14 @@ func (c *Client) CommitByHive(ctx context.Context, repo, sha string) (bool, erro return true, nil } } - // The author counts only by a login resolved to the App bot: a signature - // never covers the author address, so a verified commit proves nothing - // about an email-only author match. + // The author counts only by a login resolved to the App bot on a commit + // GitHub verified: a signature never covers the author address, so a + // verified commit proves nothing about an email-only author match, and an + // unverified one proves nothing about a login GitHub derived from a + // spoofable noreply address. + if !rc.GetCommit().GetVerification().GetVerified() { + return false, nil + } authorLogin := safeGetLogin(rc.GetAuthor()) return authorLogin != "" && c.hiveCommitIdentity(authorLogin, rc.GetCommit().GetAuthor().GetEmail()), nil } diff --git a/src/pkg/github/pr_merge_state_commit_by_hive_test.go b/src/pkg/github/pr_merge_state_commit_by_hive_test.go index 56a6ccc31b..1279aabd81 100644 --- a/src/pkg/github/pr_merge_state_commit_by_hive_test.go +++ b/src/pkg/github/pr_merge_state_commit_by_hive_test.go @@ -12,7 +12,9 @@ import ( // hive's own only on a commit GitHub verified; a login resolved to the App // bot counts whatever the verification. GitHub's verification binds the // signing key to the committer address only, so an email-only author match -// never counts, verified or not (hivecommons/hive#15182). +// never counts, verified or not (hivecommons/hive#15182); an author login +// resolved to the App bot counts only on a verified commit, since GitHub +// derives it from the free-text author email (hivecommons/hive#15421). func TestCommitByHive(t *testing.T) { t.Setenv(signedTrailerDomainEnv, "") type identity struct{ login, email string } @@ -35,7 +37,13 @@ func TestCommitByHive(t *testing.T) { {"person committer, email-only bot noreply author, verified", identity{"", "1+hive-app[bot]@users.noreply.github.com"}, identity{"alice", "alice@example.com"}, map[string]any{"verified": true}, false}, // update-branch under the App: author resolves to the bot, GitHub commits. {"bot login author, web-flow committer", identity{reconcileBot, "1+hive-app[bot]@users.noreply.github.com"}, identity{"web-flow", "noreply@github.com"}, map[string]any{"verified": true}, true}, - {"bot login author, web-flow committer, unverified", identity{reconcileBot, "1+hive-app[bot]@users.noreply.github.com"}, identity{"web-flow", "noreply@github.com"}, nil, true}, + {"bot login author, web-flow committer, unverified", identity{reconcileBot, "1+hive-app[bot]@users.noreply.github.com"}, identity{"web-flow", "noreply@github.com"}, nil, false}, + // A pusher setting user.email to the App's noreply address gets the bot + // login resolved as author on an unsigned commit (hivecommons/hive#15421). + {"spoofed bot login author, person committer, unverified", identity{reconcileBot, "1+hive-app[bot]@users.noreply.github.com"}, identity{"alice", "alice@example.com"}, map[string]any{"verified": false}, false}, + {"spoofed bot login author, no committer login, no verification", identity{reconcileBot, "1+hive-app[bot]@users.noreply.github.com"}, identity{"", "alice@example.com"}, nil, false}, + // The hive's own unsigned push: the committer resolves to the App bot. + {"bot login author, bot login committer, unverified", identity{reconcileBot, "1+hive-app[bot]@users.noreply.github.com"}, identity{reconcileBot, "1+hive-app[bot]@users.noreply.github.com"}, map[string]any{"verified": false}, true}, // The fixer's rebase keeps the person as author; the hive commits. {"person author, email-only pane committer, verified", identity{"alice", "alice@example.com"}, identity{"", "fixer@hive.kubestellar.io"}, map[string]any{"verified": true}, true}, {"person author, email-only pane committer, unverified", identity{"alice", "alice@example.com"}, identity{"", "fixer@hive.kubestellar.io"}, map[string]any{"verified": false}, false},