Skip to content

Harden pull_request_target workflows against untrusted checkout#24461

Open
stuartparmenter wants to merge 1 commit into
bevyengine:mainfrom
stuartparmenter:secure-workflows
Open

Harden pull_request_target workflows against untrusted checkout#24461
stuartparmenter wants to merge 1 commit into
bevyengine:mainfrom
stuartparmenter:secure-workflows

Conversation

@stuartparmenter
Copy link
Copy Markdown
Contributor

Objective

I've been going through a lot of my github workflows lately to try and tighten them, and wanted to see if there were any obvious issues in the Bevy ones. They seem generally safe as-is, but can be hardened further to avoid future issues.

The action-on-PR-labeled.yml workflow runs on pull_request_target, which grants it write permissions on the repo with access to secrets. It was checking out the PR's head SHA (ref: ${{ github.event.pull_request.head.sha }}) and running git against it in order to detect whether the PR touched the migration-guides / release-notes directories.

Solution

  • Detect changed files via the GitHub API (github.rest.pulls.listFiles) inside the existing github-script step instead of checking out the PR head. No untrusted code ever lands on the privileged runner.
  • Add a github.repository == 'bevyengine/bevy' guard to both pull_request_target jobs and to welcome.yml, so forks don't run stale/privileged copies of these workflows.

Testing

  • Workflow-only change; nothing to run locally.
  • Best validated by exercising the labels (M-Migration-Guide, M-Release-Note) on a test PR once merged.

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Build-System Related to build systems or continuous integration S-Needs-Review Needs reviewer attention (from anyone!) to move forward P-Security Relevant to the security of Bevy's users or infrastructure. labels May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Build-System Related to build systems or continuous integration C-Bug An unexpected or incorrect behavior P-Security Relevant to the security of Bevy's users or infrastructure. S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants