Skip to content

Trust same-repository bot PRs triggered by labels - #72074

Merged
pelikhan merged 7 commits into
mainfrom
copilot/checkout-pr-branch-bot-exception
Oct 26, 2026
Merged

pelikhan merged 7 commits into
mainfrom
copilot/checkout-pr-branch-bot-exception

Conversation

Copilot AI commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

GitHub App actors on same-repository PRs can receive none from the collaborator-permission endpoint, causing label-triggered checkout to fail. Extend the existing same-repository bot exception to labeled events.

  • Trust boundary: Preserve the existing sender identity and head/base/runtime repository ID checks; forked PRs still use the collaborator-permission check.
  • Coverage: Test labeled events for both pull_request and pull_request_target, including fail-closed cases.
const TRUSTED_BOT_PR_ACTIONS = ["opened", "synchronize", "ready_for_review", "reopened", "labeled"];

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bot exception for labeled pull requests Trust same-repository bot PRs triggered by labels Oct 26, 2026
Copilot AI requested a review from pelikhan October 26, 2026 11:44
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot

  • update compiler threat model, TLA+ specs
  • GitHub actions expert security review

@pelikhan
pelikhan marked this pull request as ready for review October 26, 2026 11:57
Copilot AI max review requested due to automatic review settings October 26, 2026 11:58
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · gpt56 · ~6 AIC · ⌖ ~6 AIC · ⊞ 14.8K · ◷

Generated by Ponytail Reviewer for #72074

Copilot AI commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

  • update compiler threat model, TLA+ specs
  • GitHub actions expert security review

Updated RS-05a and the compiler threat-model mapping, extended the checkout TLA+ model for labeled, and added fail-closed pull_request_target cases. CJS lint and all 210 checkout tests passed; the 27 model-harness tests passed. The GitHub Actions security review found no confirmed vulnerabilities. TLC/Z3 execution remains pending because the pinned tools are unavailable. Commit: 30f20ec.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · sonnet50 · ~12 AIC · ⌖ ~16 AIC · ◇ ~5 AIC · ⊞ 12.7K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · opus55 · ~11 AIC · ⌖ ~33 AIC · ◇ ~1 AIC · ⊞ 1.9K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-10-26T12:04:06Z
review_event: REQUEST_CHANGES
top_themes:
  - labeled-event trust boundary expands privileged PR-head checkout
files_reviewed:
  - actions/setup/js/checkout_pr_branch.cjs
  - actions/setup/js/checkout_pr_branch.test.cjs
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Request changes

The new trust exception broadens privileged PR-head checkout to labeled events without preserving the prior metadata-event boundary. A bot/app able to add labels but lacking collaborator code-execution permission can now trigger checkout of arbitrary PR code under the workflow's permissions. See the inline comment for the required narrowing or justification.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

Comment thread actions/setup/js/checkout_pr_branch.cjs Outdated
const { ERR_API, ERR_PERMISSION } = require("./error_codes.cjs");
const TRUSTED_CHECKOUT_PERMISSIONS = ["write", "maintain", "admin"];
const TRUSTED_BOT_PR_ACTIONS = ["opened", "synchronize", "ready_for_review", "reopened"];
const TRUSTED_BOT_PR_ACTIONS = ["opened", "synchronize", "ready_for_review", "reopened", "labeled"];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding labeled to this allowlist lets a same-repository bot/app bypass collaborator verification on a metadata-only event, so an actor that can add labels but is not trusted for code execution can cause the workflow to fetch and execute arbitrary PR head code with its existing permissions.

💡 Why this matters

The previous test explicitly treated labeled as an untrusted action, and label mutation generally requires less repository authority than creating or updating PR code. Either preserve the permission check for labeled, or constrain this exception to a verifiable, narrowly scoped trusted label-routing path and document that security decision next to the allowlist.

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.

Removed labeled from TRUSTED_BOT_PR_ACTIONS; same-repository label events now use the collaborator permission check. Added fail-closed coverage for both PR event types and aligned the RS-05a docs/model. Commit: 72ce6eb.

Comment thread actions/setup/js/checkout_pr_branch.cjs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The change expands a security-sensitive checkout exception while formal revalidation remains pending.

2 open issues
What changed in this PR

Extends gh-aw’s PR checkout trust exception to label-triggered, same-repository bot PRs, addressing #71151 while preserving sender and repository-identity checks.

Changes:

  • Adds labeled to trusted bot actions for pull_request and pull_request_target.
  • Adds positive and fail-closed regression cases for both triggers.
  • Updates security specifications, validation records, and the bounded authorization model.
File Description
specs/​workflow-security/​README.md Documents labeled in checkout-model coverage.
specs/​workflow-security/​CommentTriggeredPRCheckout.tla Adds labeled to modeled and supported actions.
specs/​security-architecture-spec.md Updates the normative exception and version history.
specs/​security-architecture-spec-validation.md Updates coverage mapping and validation status.
specs/​compiler-threat-detection-spec.md Clarifies the runtime exception’s scope.
specs/​compiler-threat-detection-changelog.md Records the clarification and mapping audit.
actions/​setup/​js/​checkout_pr_branch.test.cjs Covers trusted labeled events and rejected provenance cases.
actions/​setup/​js/​checkout_pr_branch.cjs Extends the trusted bot action allowlist.

Review effort: Max

## Executive Summary

⚠️ **VALIDATION STATUS**: The specification reflected the implementation at the time of full validation on 2026-07-15 and RS-05a targeted revalidation on 2026-10-09. The v1.1.2 review-checkout update and v1.1.3 branch-event update have not yet received targeted revalidation (see §7b); this document does not claim that they have. These validations do not replace the full revalidation required by the policy in `security-architecture-spec.md` §11.
⚠️ **VALIDATION STATUS**: The specification reflected the implementation at the time of full validation on 2026-07-15 and RS-05a targeted revalidation through v1.1.5 on 2026-10-26. The v1.1.2 review-checkout update and v1.1.3–v1.1.5 branch-event updates have not yet received full formal revalidation (see §7b); this document does not claim that they have. These validations do not replace the full revalidation required by the policy in `security-architecture-spec.md` §11.

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.

Restored the last completed targeted formal revalidation to v1.1.1 / 2026-10-09. The validation summary now separates runtime evidence for v1.1.3 and v1.1.5 and identifies v1.1.4 as transport-security work. Commit: 72ce6eb.

| bot/app actor with write-or-higher repository permission allowed | actor trust |
| bot/app actor without write-or-higher repository permission rejected for `workflow_dispatch`, `issue_comment`, `pull_request_review_comment`, and `pull_request_review` | actor trust |
| same-repository bot `opened`, `synchronize`, `ready_for_review`, and `reopened` PR events allowed only when sender and runtime, head, and base repository IDs match; `ready_for_review` and `reopened` are lifecycle actions, not branch-push evidence | actor trust exception |
| same-repository bot `opened`, `synchronize`, `ready_for_review`, `reopened`, and `labeled` PR events allowed only when sender and runtime, head, and base repository IDs match; lifecycle/metadata actions are not branch-push evidence | actor trust exception |

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.

Because labeled now stays outside the trusted bypass after the security fix, I kept the actual trusted action list limited to opened, synchronize, ready_for_review, and reopened, and updated the negative-case wording to name labeled and edited as actions outside that allowlist. Commit: 72ce6eb.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — this is a clean, well-scoped fix. APPROVE.

📋 Analysis

What was checked

  • Trust boundary preserved: labeled was added to TRUSTED_BOT_PR_ACTIONS inside the same same-repository check that already requires sender.type === "Bot", sender.login === actor, and positive, equal runtime/head/base repository IDs. Forked PRs and identity mismatches still fall through to the collaborator-permission check — no new bypass surface.
  • Root cause addressed, not just symptom: this closes the exact gap described in #71151 (same class as #69311), extending the existing exception to the one remaining lifecycle action that previously forced a failing getCollaboratorPermissionLevel call for App senders.
  • Test coverage (/tdd): positive cases added for labeled on both pull_request and pull_request_target; negative/fail-closed cases added for forked PR, mismatched base repo ID, different sender, and non-bot sender under labeled. The pre-existing "metadata-only PR event" negative case was correctly renamed to "untrusted PR action" (using edited) since labeled moved into the trusted set — this avoids a stale/contradictory test name.
  • Docs/spec consistency: security-architecture-spec.md (v1.1.4→v1.1.5), its changelog, the validation doc, and the CommentTriggeredPRCheckout.tla formal model were all updated in lockstep with the code change, keeping the bounded TLA+ coverage honest.

Minor observations (non-blocking)

  • Could not execute npm/vitest in this sandbox (no network access to the registry), so the new test cases were verified by static reading only, not by running the suite. The logic and assertions read correctly and mirror the existing ready_for_review/reopened patterns exactly.

Positive highlights

  • ✅ Symmetric test matrix across pull_request and pull_request_target for every new negative case
  • ✅ Spec, changelog, validation doc, and TLA+ model updated together — no doc drift
  • ✅ No widening of the exception beyond the single lifecycle action needed to fix the bug

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · ~69 AIC · ⌖ ~15 AIC · ⊞ 10.2K
Comment /matt to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/checkout_pr_branch.cjs:40): Adding labeled to this allowlist lets a same-repository bot/app bypass collaborator verification on a metadata-only event, so an actor that can add labels but is not trusted for code execution can cause the workflow to fetch and execute arbitrary PR head code with its existing permissions. - Trust same-repository bot PRs triggered by labels #72074 (comment)
  3. Review (actions/setup/js/checkout_pr_branch.cjs:40): Excessive agency risk: adding 'labeled' to the same-repository bot PR-action bypass allows any Bot sender who applies a label (not necessarily the PR author/pusher) to skip the collaborator write-or-higher permission floor on pull_request/pull_request_target. This can let a bot with only issue/label privileges trigger PR head checkout under pull_request_target base-repo credentials (and any subsequent agent steps) without an independent verification that the bot has write-or-higher access. Consider tightening the bypass (e.g., require pull_request.user.login matches the bot, or add an independent permission/installation authorization check specific to labeled) to avoid privilege escalation via label events. - Trust same-repository bot PRs triggered by labels #72074 (comment)
  4. Review (specs/security-architecture-spec-validation.md:13): The header and summary now report targeted revalidation through v1.1.5, but §7b says only runtime tests passed and targeted formal revalidation remains pending. Keep the last completed targeted revalidation at v1.1.1 / 2026-10-09 and record the new runtime results separately. List v1.1.3 and v1.1.5 explicitly; v1.1.4 concerns transport security, not branch events. - Trust same-repository bot PRs triggered by labels #72074 (comment)
  5. Review (specs/security-architecture-spec-validation.md:480): The action list at line 442 still omits labeled, and line 483 still describes the old labeled rejection as a "metadata-only action," contradicting this updated row. Add labeled to the former list and describe the latter case as an action outside the trusted allowlist, such as edited. - Trust same-repository bot PRs triggered by labels #72074 (comment)

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 30f20ec
Sous-chef work: 27e631e2c1dfb3b6d98e8aa07569f0d7ef602740f759b362db6027f5f9cb35f2 81a447f2d3a83aa14dd45722f87167da670e6cf78dc1dc1a8688148edb753c86 96420bec46b2befa2378ebb645e2fc3d276a183f3e020ca5f638a672a2d945c4 bcf3236f4084b4a8013e948da56e840b21f0b3516b5d137f52963a2af567aeed
Sous-chef state: dadb2a7b025ae2721604fd9e0af65cb84d673ec5e01f865507d1391508dad349

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · ~7 AIC · ⌖ ~8 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

Copilot AI and others added 2 commits October 26, 2026 12:48
…ranch-bot-exception

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot fix ci failures

Copilot AI and others added 2 commits October 26, 2026 14:24
…ranch-bot-exception

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot fix ci failures

Fixed the CJS shard failure in nvx_assets.test.cjs: the copied /bin/echo fixture is now invoked with argv0: "echo", preventing multicall coreutils from dispatching on copilot. The targeted NVX tests and final make agent-report-progress passed. Commit: bb509f70. CI was not re-triggered.

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes....

Merged latest main with make merge-main (ac511132) and fixed the CJS shard failure (bb509f70). make fmt, make lint, and make agent-report-progress passed. The existing Copilot replies already address the listed review threads, but I could not resolve them: this environment has no GitHub mutation credentials or thread-resolution tool. CI was not re-triggered; it needs a maintainer handoff.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.0.1

@github-actions
github-actions Bot deleted the copilot/checkout-pr-branch-bot-exception branch November 3, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

checkout_pr_branch: same-repository bot exception does not cover pull_request labeled

5 participants