Skip to content

Extend confused deputy protection to pull_request_target - #52976

Merged
pelikhan merged 3 commits into
mainfrom
copilot/extend-isconfuseddeputyattack
Aug 15, 2026
Merged

Extend confused deputy protection to pull_request_target#52976
pelikhan merged 3 commits into
mainfrom
copilot/extend-isconfuseddeputyattack

Conversation

CopilotAI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

pull_request_target synchronize events bypassed the confused-deputy check applied to equivalent pull_request events, allowing a bot actor to differ from the PR author.

  • Detection

    • Apply actor-to-author validation to both PR event types:
      eventName==="pull_request"||eventName==="pull_request_target"
    • Preserve existing bot-only and synchronize-only safeguards.
  • Coverage

    • Add cases for mismatched bot actors, matching PR authors, and legitimate human collaboration.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI requested a review from pelikhanAugust 15, 2026 22:10
@pelikhan
pelikhan marked this pull request as ready for review August 15, 2026 22:31
CopilotAI balanced review requested due to automatic review settings August 15, 2026 22:31

CopilotAI 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.

Pull request overview

Extends confused-deputy protection to pull_request_target synchronization events.

Changes:

  • Applies bot actor-to-PR-author validation to both PR event types.
  • Adds coverage for malicious mismatches and legitimate actors.
Show a summary per file
FileDescription
actions/setup/js/check_permissions_utils.cjsExtends event validation to pull_request_target.
actions/setup/js/check_permissions_utils.test.cjsTests matching, mismatched, and human actors.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

github-actionsBot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #52976 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actionsBot commented Aug 15, 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-actionsBot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship.

Generated by Ponytail Reviewer for #52976

@github-actions

github-actionsBot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Reviewed PR #52976 locally; no actionable review comments or GitHub writes were needed because the patch is a narrow correctness fix with targeted tests and I found no blocking issues.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actionsBot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actionsgithub-actionsBot 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.

The change is correct and well-tested. Extending the confused deputy guard to pull_request_target is the right call — that trigger runs in the base-branch context with write permissions, making it more susceptible to the attack, not less. The three new test cases cover all relevant scenarios (bot-mismatch → true, bot-match → false, human → false). No issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 14.3 AIC · ⌖ 7 AIC · ⊞ 5.6K

@github-actionsgithub-actionsBot 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 — one minor gap in test coverage, otherwise approving.

📋 Key Themes & Highlights

Key Themes

  • Security fix is correct: The one-line condition change (|| eventName === "pull_request_target") is minimal and precisely closes the bypass.
  • Test coverage is good but not complete: Three new tests cover the attack case, the safe case, and the human-collaborator case. The only gap is a non-synchronize action for pull_request_target, which the pull_request suite already covers.

Positive Highlights

  • ✅ Root cause properly addressed — the condition now mirrors pull_request exactly.
  • ✅ Comment updated to reflect both event types.
  • ✅ Tests read as specifications (clear arrange/act/assert, descriptive names).
  • ✅ No collateral changes — the fix is surgical.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 23.6 AIC · ⌖ 8.95 AIC · ⊞ 7.7K
Comment /matt to run again


it("should return false for pull_request_review when actor matches review author (genuine review)", () => {
const payload = {
pull_request: { user: { login: "pr-author" } },

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.

[/tdd] Missing edge case: no test covers pull_request_target with a non-synchronize action (e.g. labeled). The existing pull_request suite has an equivalent case — adding one here fully mirrors coverage and guards against future regressions if the condition logic changes.

💡 Suggested test
it("should return false for pull_request_target:labeled (non-synchronize action)",()=>{constpayload={action: "labeled",pull_request: {user: {login: "alice"}}};expect(isConfusedDeputyAttack("dependabot[bot]","pull_request_target",payload)).toBe(false);});

@copilot please address this.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Added the non-synchronizepull_request_target:labeled coverage in 4866db1. The focused setup JS test and make agent-report-progress both pass locally.

@github-actionsgithub-actionsBot mentioned this pull request Aug 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 90/100 — Excellent

Analyzed 3 test(s): 3 design, 0 implementation, 0 violation(s).

📊 Metrics (3 tests)
MetricValue
Analyzed3 (Go: 0, JS: 3)
✅ Design3 (100%)
⚠️ Implementation0 (0%)
Edge/error coverage3 (100%)
Duplicate clusters0
InflationYes (5:1 ratio)
🚨 Violations0
TestFileClassificationNotes
pull_request_target:synchronize bot actor differs from PR authorcheck_permissions_utils.test.cjs:790design_test, high_value✅ Detects confused deputy security invariant
pull_request_target:synchronize bot actor matches PR authorcheck_permissions_utils.test.cjs:795design_test, high_value✅ Prevents false positives on legitimate bot behavior
pull_request_target:synchronize human collaboratorcheck_permissions_utils.test.cjs:800design_test, high_value✅ Validates legitimate human collaboration

Analysis

This PR extends confused deputy attack detection to pull_request_target events. The three new test cases provide comprehensive coverage:

  1. Primary invariant (test:1): Detects the security issue when a bot actor differs from the PR author on pull_request_target:synchronize events
  2. False positive prevention (test:2): Legitimate bots that are the PR author are not flagged
  3. Human collaboration (test:3): Human team members pushing to PRs they don't own remains allowed (permissions are validated separately)

All tests are behavioral contracts enforcing the security design, not implementation details. The 5:1 test-to-production ratio is justified: expanding event-type coverage from pull_request{pull_request, pull_request_target} requires new test rows. No padding or redundant assertions detected.

Verdict

passed. 0% implementation tests (threshold: 30%). All new tests enforce security invariants with high behavioral value.

🧪 Test quality analysis by Test Quality Sentinel · haiku45 · 24.4 AIC · ⌖ 3.31 AIC · ⊞ 7.9K ·
Comment /review to run again

@github-actionsgithub-actionsBot 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.

✅ Test Quality Sentinel: 90/100 (Excellent). 0% implementation tests (threshold: 30%). All new tests enforce security invariants with high behavioral value.

@pelikhan

Copy link
Copy Markdown
Collaborator

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage for maintainer-ready follow-up:

Please refresh the branch if needed, fix the remaining failed check, and run the pr-finisher skill before handing this PR back to maintainers.

Outstanding review items (newest first):

  • No unresolved reviewer follow-up was found in the current compact triage context.

Failed checks from the compact candidate set:

Branch update was requested automatically for this run when GitHub allows it.
Run context: https://github.com/github/gh-aw/actions/runs/31914206398

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.56 AIC · ⌖ 6.97 AIC · ⊞ 8.7K ·
Comment /souschef to run again

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

CopilotAI commented Aug 15, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot fix lint js https://github.com/github/gh-aw/actions/runs/31912360371/job/95081870383?pr=52976

Fixed in e3d851e6aa. make agent-report-progress now passes, including JS lint and eslint-factory tests.

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

CopilotAI commented Aug 15, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot Quick triage for maintainer-ready follow-up:

Please refresh the branch if needed, fix the remaining failed check, and run the pr-finisher skill before handing this PR back to maintainers....

Completed pr-finisher pass in 4866db1.

  • Reviews: addressed the remaining GitHub Actions review thread by adding pull_request_target:labeled coverage.
  • Checks: prior lint-js failures were root-caused to Prettier formatting and fixed in e3d851e; local make agent-report-progress passes on the current branch.
  • Mergeability: PR is open and not draft; no branch refresh was indicated as required by the PR API.

CI on the agent-pushed HEAD is stale and needs a maintainer re-trigger before merge.

CopilotAI requested a review from gh-aw-botAugust 15, 2026 23:31
@pelikhan
pelikhan merged commit 3cf910d into mainAug 15, 2026
8 of 9 checks passed
@pelikhan
pelikhan deleted the copilot/extend-isconfuseddeputyattack branch August 15, 2026 23:43
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.0

Sign up for freeto 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.

4 participants

@pelikhan@gh-aw-bot