Skip to content

fix: add repository guard to workflow_run test jobs to prevent fork code execution#4304

Open
adilburaksen wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
adilburaksen:fix/workflow-run-repository-guard
Open

fix: add repository guard to workflow_run test jobs to prevent fork code execution#4304
adilburaksen wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
adilburaksen:fix/workflow-run-repository-guard

Conversation

@adilburaksen
Copy link
Copy Markdown

Summary

custard-run.yaml and custard-run-dev.yaml both trigger on workflow_run when the Custard CI workflow starts. The test job checks out and executes the fork's code with live GCP credentials (kokoro-system-test@long-door-651) without verifying that the triggering workflow came from the same repository.

Attack: Any GitHub user with a previously merged PR (bypassing first-time-contributor approval) can open a fork PR and have their Makefile execute on Google's CI runner with live GCP WIF credentials.

Fix

Adds an if: guard to the test job in both workflow files:

if: |
  needs.affected.outputs.paths != '[]' &&
  (github.event_name != 'workflow_run' ||
   github.event.workflow_run.head_repository.full_name == github.repository)

This ensures that for workflow_run triggers, only PRs from the same repository (not forks) proceed to the GCP-authenticated test step.

Files Changed

  • .github/workflows/custard-run.yaml — added repository guard to test job
  • .github/workflows/custard-run-dev.yaml — same fix applied

References

@adilburaksen adilburaksen requested review from a team as code owners April 28, 2026 17:10
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@product-auto-label product-auto-label Bot added samples Issues that are directly related to samples. api: workflows Issues related to the Workflows API. labels Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: workflows Issues related to the Workflows API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant