Skip to content

fix(source-control): pr-merge's affected-suites check trusts a green run on any commit named main #9466

Closed

Description

@kyle-sexton

Problem

_Context.affected in plugins/source-control/skills/babysit-prs/scripts/babysit_postmerge.py (lines 1061-1074 on main) picks the newest green full run whose head_branch equals the branch name. It never checks that the run's head_sha is on that branch. affected_suites (lines 751-808) then checks that commit out and runs its PLAN_SCRIPT to decide which suites a red full run's merges could have broken.

A workflow_dispatch run started on a tag named main reports head_branch: main. The merge job's checkout uses fetch-depth: 0 (.github/workflows/pr-merge.yml:430), which fetches every tag and branch, so that commit is present locally. The repository has no tag ruleset (gh api repos/melodic-software/claude-code-plugins/rulesets lists only branch rulesets).

Risk

  • Attacker must already hold: write access (to push a tag and dispatch pr-require-checks).
  • Impact: code the attacker wrote runs in the pr-merge job. Environment variables containing TOKEN are unset, and the checkout uses persist-credentials: false. The plan can also return a narrow suite set, so a red main run looks unaffected and pr-merge files no demotion.
  • Severity: IMPORTANT, not CRITICAL. A write-access holder already has other paths, but this one gets past the post-merge breaker without anyone noticing.

Fix

In affected, keep a green run only when self.contains(green.head_sha, self._branch_tip()) holds (the helper already exists at about line 1323). Apply the same check to _baseline (lines 1127-1135), which uses the same head_branch filter. Add a test where a green run on a commit that is not on main is ignored.

Found by the security reviewer on #9453 (finding 7) and verified against main at 2372581.

Activity

  1. added
    status: ready
    on Oct 23, 2026
  2. added theissue type on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: ready

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions