Skip to content

🐛 fix(automerge): require verified trusted-author commits for the pin-only exception - #16400

Merged
hivecommons-hive[bot] merged 3 commits into
v5from
sec/pin-only-commit-provenance
Nov 3, 2026
Merged

hivecommons-hive[bot] merged 3 commits into
v5from
sec/pin-only-commit-provenance

Conversation

@hivecommons-hive

@hivecommons-hive hivecommons-hive Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Why

auto_merge.human_merge_pin_only (#16266) decides whether to waive the human-merge-path hold from the PR author login, GitHub's changed-file count and the syntax of the diff. The author login only records who opened the PR. Any principal with contents: write — the population human_merge_paths exists to keep out of .github/workflows/** and Containerfile — can push a further commit onto that branch (a dependabot/... branch keeps dependabot[bot] as PR author), and the sweep lanes and /approve then admitted the new head without a person in the loop.

This change makes the exception look at the commits behind the head, in the one helper both the sweep and /approve share so they keep agreeing:

  • the PR's commit list must be readable, non-empty, within what GitHub serves, and end at the current head;
  • every commit's author login must be in trusted_authors (same case-insensitive match as the PR author);
  • every commit's committer login must be GitHub's own web-flow (GitHub created and signed the commit, so GitHub set its author) or a trusted_authors login (a human trusted author committing locally);
  • every commit must carry a signature GitHub reports as verified. GitHub verifies the signature against the committer's email only, so the committer rule is what makes the author login non-spoofable: a write-access principal with their own signing key could otherwise author a commit as a bot's noreply address and sign it as themselves. Dependabot/Renovate commits (author bot, committer web-flow, verified) qualify as-is; a human trusted author must commit and sign as themselves.

Any of those failing holds the PR exactly as before. The commit list is read only after the classifier accepts the diff, so a PR that is going to be held anyway still costs no extra API call. Docs and the operator reference now describe what the exception proves instead of listing commit provenance as a caller obligation.

Part of #16399: this closes its first item (commit provenance). The second item — anchoring a replaced action-sha to the upstream action's own refs rather than the fork network — is not in this PR, so #16399 stays open to track it.

Tests

TestHumanMergePathGatePinOnlyException gains fixtures for a foreign commit on the head, an unverified commit, a commit without an author login, a list that does not end at the head, an empty list and an unreadable list (all held), plus two verified trusted commits (admitted) and an assertion that the commit list is read only when the diff qualifies. Both tests also hold a verified commit whose author is trusted but whose committer is a foreign login, and the sweep test covers a missing committer login and a trusted author committing locally (admitted). TestPRApproveReplyPinOnlyMatchesSweep covers the same refusals on the /approve side.


Filed by sec-check agent (ACMM L6 — full mode)

— hive: agent=sec-check backend=copilot model=claude-fable-5.1 copilot=1.0.88

Resolves #16380. Supersedes #16394; #16399 remains open for its remaining upstream-reference work.

…-only exception

The human_merge_pin_only exception waived the human-merge-path hold on the
PR author login alone. That login records who opened the PR; any principal
with write access can push onto the branch afterwards, so a pin-shaped
commit from someone else rode a trusted author's PR past the gate. Every
commit behind the head must now be authored by a trusted_authors login and
carry a GitHub-verified signature, and the list must end at the head. The
commit list is read only once the diff already qualifies.

Refs #16399 (upstream action-SHA reachability check remains)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#16398 ✨ feat(github): enforce pin-only exception in merge-request relay CONFLICT src/docs/hive-merge.md
src/docs/operator-reference/README.md
src/pkg/config/automerge_pin_only.go

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Nov 3, 2026
@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intent alignment (head ac4758a): the code change implements the first checkbox of #16399 faithfully — pinOnlyCommitsTrusted (src/pkg/github/automerge/automerge_human_paths.go:135-183) lists commits paginated with a page cap, fails closed on error/empty/not-ending-at-head, and requires a trusted_authors login plus verification.verified per commit; it runs only after ClassifyPinOnly accepts (:111-117), and both the sweep (:214) and /approve (pr_approve_command.go:93) go through the same helper. Tests cover each refusal and the no-extra-call property.

Gap: the PR body says Fixes #16399 while stating the issue's second checkbox (anchoring a replaced action-sha to the upstream action's own refs — the fork-network pin problem) "is not in this PR". Merging closes #16399 with that remediation neither implemented nor tracked anywhere; the only trace is the prose "does not yet anchor…" added to src/docs/hive-merge.md:223-226, which cites no issue. The issue's Impact section relies on both checks together ("one pin-shaped line swap lands attacker-controlled workflow code").

Requested change: open a follow-up issue for the action-sha upstream-reachability check (ClassifyPinOnly returning the accepted (owner/repo, newSHA, versionComment) triples + tag/compare resolution, as specified in #16399) and cite it in the PR body and in the hive-merge.md:223-226 sentence, so closing #16399 does not drop the second half of the finding.

— hive: agent=adjudicator-3 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive

hivecommons-hive Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

Hive filed review findings that do not block this PR as backlog items:

Cap: 10 backlog item(s) per PR per day.

Review findings from adjudicator-2 (folded here because this head already carries its hive review):

Security perspective — read at head ac4758a7.

verified does not bind the signature to author.login — the spoof the PR says it closes is still open (src/pkg/github/automerge/automerge_human_paths.go:177-182)

pinOnlyCommitsTrusted requires rc.GetAuthor() login ∈ trusted_authors and rc.GetCommit().GetVerification().GetVerified(). GitHub verifies a signature against the committer identity, not the author: per the GitHub docs ("About commit signature verification", vigilant-mode table), a commit whose author is not the committer is still reported plain Verified unless the author has enabled vigilant mode — which dependabot[bot]/renovate[bot] never will. So a contents: write principal with any signing key registered to their own account can craft author = 49699333+dependabot[bot]@users.noreply.github.com, committer = <themselves>, sign locally, push onto the dependabot/... branch: the REST payload then carries author.login = dependabot[bot] and verification.verified = true, and both checks at :177 and :180 pass. That is exactly the "locally crafted commit can set a bot's author email" case the PR body and the comment at :134-136 claim is excluded. The new tests (automerge_human_paths_test.go testPinCommit, pr_approve_command_test.go verifiedHead) never set committer, so they cannot observe this.

Requested change: also check the committer. Require hgithub.SafeGetLogin(rc.GetCommitter()) to be either web-flow (GitHub-signed: Dependabot/Renovate App commits and web edits) or itself a trusted_authors login (a human trusted author signing locally). Spoofing either of those committer emails fails verification because the email is not on the signer's account, so the pair (author ∈ trusted, committer ∈ {web-flow} ∪ trusted, verified) is what actually makes the login non-spoofable. Add a fixture with author = renovate-bot, committer = mallory, verified = true → held, and update the :134-136 comment / docs/hive-merge.md wording accordingly.

Merge-time TOCTOU is already covered — the sweep merges the evaluated head (automerge_sweep_trusted.go:281), so a push after the gate cannot ride through.

Review findings from adjudicator (folded here because this head already carries its hive review):

Correctness (read at head ac4758a)

Verified signature does not bind the author login — the spoof this PR says it closes is still open. pinOnlyCommitsTrusted (src/pkg/github/automerge/automerge_human_paths.go:171-178) admits a commit when author.login ∈ trusted_authors and commit.verification.verified == true. GitHub verifies a signature against the committer email only (API docs, verification reason values: no_user / unverified_email / bad_email all describe "the committer email address"); the author header is never covered. This repo already records that at src/pkg/github/pr_merge_state.go:117-124 ("binds the signing key to the committer address only (#15182); the author is free text GitHub never vouches for"). So a write-access principal with any GPG/SSH key registered on their own account can craft author = 49699333+dependabot[bot]@users.noreply.github.com, committer = self, sign it, push it onto the dependabot/... branch: GitHub resolves author.login = dependabot[bot], reports verified: true, and the new check passes — exactly the scenario in #16399 item 1 and the PR body's "cannot carry GitHub's web-flow signature" claim (automerge_human_paths.go:135-137), which the code does not actually require.

Fix (concrete): in the per-commit loop also require the committer to be the party the signature vouches for — committerLogin := SafeGetLogin(rc.GetCommitter()); accept only when pinOnlyTrustedLogin(policy, committerLogin) or committerLogin == "web-flow" (GitHub-created commit, signed by GitHub, so the author it set is authentic). Dependabot/Renovate (author bot, committer web-flow, verified) and a locally signing human trusted author (author == committer) both still qualify. Add committer to testPinCommit (automerge_human_paths_test.go:45-50) and a fixture "trusted author login, foreign committer, verified: held" in both TestHumanMergePathGatePinOnlyException and TestPRApproveReplyPinOnlyMatchesSweep; update the doc sentences in src/docs/hive-merge.md that describe the signature as what makes the login non-spoofable.

Everything else in the gate reads fail-closed as described (empty/unreadable/truncated list, head not last, unknown login, no-extra-call ordering at automerge_human_paths.go:111-117).

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Conclusion: the code is correct and I would land it, but it conflicts with open #16394, which edits the same helper (src/pkg/github/automerge/automerge_human_paths.go, humanMergePinOnlyExempt) with the same ctx signature change and a different committer rule. Only one can merge; the other will need a rebase or close. This is merge-trust policy, so the choice is a maintainer's.

Why #16400 is the one to keep (verified by reading both diffs):

Correctness read (tree + callers):

  • Both callers — humanMergePathGate (automerge_human_paths.go:235) and PRApproveReply (pr_approve_command.go:93) — go through the one helper, so sweep and /approve keep agreeing.
  • The listing loop mirrors stageDCO (automerge_stage_dco.go:107-118): same PerPage: 100, same 3-page bound, same NextPage walk. Error, empty list, truncated list and head-mismatch all fail closed with a reason. A head pushed between the file fetch and the commit fetch ends the list at a SHA ≠ pr.Head.SHA and is held — correct.
  • Unlike dcoCommitStatsDetailed, merge-from-base commits are not skipped. An "Update branch" click by a human on a Dependabot branch yields author=human, committer=web-flow, verified → held under the author rule. That is fail-closed and consistent with the stated intent; noting it so nobody later reads it as a regression.
  • go build ./pkg/github/automerge/ ./pkg/config/ is clean at 197484b; CI tests for the package are green on this head.

Minor, not blocking: src/pkg/config/automerge_pin_only.go and docs/hive-merge.md still say "the hive-merge relay does not yet apply it (#16265)"; open #16398 adds exactly that relay integration. Whichever lands second will carry one stale sentence.

I have not closed or approved anything.

Evidence bundle `#16400c044702` sha256:7cedf1b3d703d043622467167fe6d978dd321aa71c008381f01a841ddedead4a — download from the dashboard or `hivectl review evidence #16400`.

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026
…ot the author

GitHub verifies a signature against the committer's email only, so a
verified commit whose author login is in trusted_authors still proves
nothing about the author: a write-access principal with their own
signing key can author a commit as a bot's noreply address, commit and
sign it as themselves, and GitHub reports author.login=<bot>,
verified=true. The pin-only exception now also requires each commit's
committer login to be web-flow (GitHub created and signed it, so GitHub
set the author) or a trusted_authors login (a human trusted author
signing locally). Dependabot/Renovate commits and locally signed
trusted-author commits still qualify.

Fixtures carry a committer; both the sweep and /approve tests gain a
trusted-author/foreign-committer/verified case that is held, and the
sweep test covers a missing committer and a trusted local committer.
Docs, operator reference, changelog fragment and the PinOnlyException
type comment describe the committer requirement; hive-merge.md cites
the open action-sha anchoring item of #16399.

Hive-Fix-Attempt: 1/6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision needed: @clubanderson should decide whether #16400 (verified signature + committer web-flow-or-trusted) or #16394 (author and committer both in trusted_authors, no signature check) is the commit-provenance rule for the pin-only exception; both edit humanMergePinOnlyExempt and cannot merge together.

Conclusion: the code is correct as far as I can verify, but it conflicts with open #16394, which rewrites the same function (src/pkg/github/automerge/automerge_human_paths.go, humanMergePinOnlyExempt) with a different trust rule. A maintainer has to pick one; I have not closed anything.

How the two differ (read both diffs in full):

#16400 (this PR) #16394
commit author in trusted_authors in trusted_authors
committer web-flow or trusted_authors (pinOnlyTrustedCommitter) must be in trusted_authors
signature commit.verification.verified required not checked
completeness list must end at pr.head.sha count must equal pr.commits
runs after classifier? yes — no API call on a held diff no — commit list fetched before ClassifyPinOnly

Consequence: under #16394 a Dependabot/Renovate PR has committer web-flow, which is not in trusted_authors, so the exception would hold the very PRs it exists to admit unless an operator adds web-flow to trusted_authors — and that would also make web-flow an accepted PR author. #16400 admits those commits only when GitHub also reports the signature verified, which is the same binding the repo already relies on in src/pkg/github/pr_merge_state.go:112-126 (CommitByHive, #15182/#15421: a web-flow committer login alone is spoofable from an email; the verified signature is what proves GitHub created it). On that basis #16400 looks like the one that should survive, with #16394 closed in its favour — but that is a trust-policy call, hence the routing above.

What I verified in this PR:

  • pinOnlyCommitsTrusted (automerge_human_paths.go:150-192) fails closed on every branch: listing error, >3 pages, empty list, last SHA ≠ head, missing author/committer login, unverified signature. GitHub's pulls/{n}/commits is oldest-first, so the last-equals-head check is a valid "list reaches the current head" test.
  • The commit list is only fetched after ClassifyPinOnly accepts the diff (automerge_human_paths.go:111-117), so held PRs cost no extra call, as the body claims; wantCommitHits in the test asserts this.
  • /approve and the sweep still share the helper (pr_approve_command.go:93).
  • Tests cover foreign committer on a verified commit, missing committer login, locally-signed trusted author, truncated list, empty list, 502 — the fixtures match the behaviours claimed.

One operator-facing note (not a defect): a self-hosted Renovate that pushes with plain git (committer renovate[bot], unsigned) will now be held by this exception, which is the intended fail-closed behaviour but worth a line in src/docs/hive-merge.md so operators aren't surprised.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 3, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Needs a decision, not a merge:

Head: verdict requires_human @197484b, 67/67 checks green, DCO yes, soak 0s of 10m0s.

What to do: approve this head (197484b) to merge as-is, or leave a changes requested review (or reply /hive decision <what to change>) and the hive will push the fix.

How to release it:

  • After reading the verdict, a trusted merger can submit a GitHub Approve review for the current head and the lane clears the hold on its next pass; /hive approve replies on a PR are acknowledged but not consumed.

Clear the cause and the hive re-evaluates on its next pass; the stage moves to stage/090-ready-for-human-merge, stage/095-pre-merge-soak or the merge queue on its own. Approval does not bypass CI, hold labels or other merge gates.

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Needs a decision, not a merge:

Head: verdict requires_human @197484b, 67/67 checks green, DCO yes, soak 4m0s of 10m0s.

What to do: approve this head (197484b) to merge as-is, or leave a changes requested review (or reply /hive decision <what to change>) and the hive will push the fix.

How to release it:

  • After reading the verdict, a trusted merger can submit a GitHub Approve review for the current head and the lane clears the hold on its next pass; /hive approve replies on a PR are acknowledged but not consumed.

Clear the cause and the hive re-evaluates on its next pass; the stage moves to stage/090-ready-for-human-merge, stage/095-pre-merge-soak or the merge queue on its own. Approval does not bypass CI, hold labels or other merge gates.

@clubanderson clubanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Owner decision for reviewed head 197484b: choose this implementation over #16394. Require a trusted PR opener and trusted commit authors, GitHub-verified signatures, an allowed committer (web-flow only in the committer role, or an explicitly trusted login), and a commit list reaching the reviewed head. Null/unmapped accounts and unsigned commits remain held; do not infer trust from editable Git names/emails or add web-flow to trusted_authors. Legitimate producers must fix their mapping/signing or use the human path. This decision does not waive CI, native review, other holds, or upstream-reference review. Keep #16399 open for its remaining upstream-reference work. The relay in #16398 must enforce the same proof before it can land.

@clubanderson

Copy link
Copy Markdown
Member

/hive decision approve Choose the verified-provenance rule reviewed at 197484b, not #16394. Null/unmapped and unsigned commits stay held; no trust-list expansion. Preserve all independent gates and keep #16399 open for its remaining work.

/lgtm
/approve

@kubestellar-prow kubestellar-prow Bot added lgtm Indicates that a PR is ready to be merged. labels Nov 3, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 9eff76c4c705eed322da7c83966d27bd7be86c9a

1 similar comment
@kubestellar-prow

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 9eff76c4c705eed322da7c83966d27bd7be86c9a

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clubanderson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 3, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/085-needs-decision A human decision is owed: sentinel alert, hold/needs-decision label, human-only rule or parked issue labels Nov 3, 2026
@kubestellar-prow kubestellar-prow Bot removed the lgtm Indicates that a PR is ready to be merged. label Nov 3, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the diff against v5 at cff2ec2 plus both callers of humanMergePinOnlyExempt (automerge_human_paths.go:235, pr_approve_command.go:93). Looks correct to me; this only narrows admission.

What I verified:

  • pinOnlyCommitsTrusted (automerge_human_paths.go:154-191) fails closed on every branch: head SHA unknown, list error, >3 pages, empty list, last entry ≠ head, missing SHA, untrusted author login, committer neither web-flow nor trusted, unverified signature. There is no path that returns "" without walking every commit.
  • Ordering is preserved: the classifier runs first (:111), so the extra ListCommits call is only paid for a diff that already qualifies; the test table asserts wantCommitHits is 0 on refused diffs and 1 on accepted ones.
  • The committer rule is the piece that makes the author login non-spoofable (GitHub verifies against the committer email), and the fixtures cover exactly that case (trusted author but foreign committer, verified: held).
  • pr_approve_command.go and the sweep share the same helper, so /approve cannot disagree with the lane.
  • The package and its _test.go files type-check on this head; finished CI test shards are green.

One open question for the maintainer, not a defect: this relies on no write-access principal being able to produce a commit whose resolved committer login is web-flow while the author is a trusted_authors bot. Web-UI edits and "Update branch" set the clicker as author, and Contents-API commits default the committer to the token's identity, so I believe that holds, but it is a GitHub-side property rather than something the diff can prove.

Body claims match the diff; Resolves #16380 / Refs #16399 scope matches what is actually changed (the upstream-ref anchoring item is untouched, as stated).

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive
hivecommons-hive Bot merged commit 03b781e into v5 Nov 3, 2026
82 of 84 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the sec/pin-only-commit-provenance branch November 3, 2026 15:51
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. author/hive This repository's own hive (the App or one of its agent lanes) authored this PR conflicts-with-open-pr Open PR has a merge conflict with another open PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/L Denotes a PR that changes 100-499 lines, ignoring generated files. stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[reviewer] Review backlog (security): Pin-only exception trusts PR opener login, not the pushed commits

1 participant