Repository navigation
Refuse fork PR checkouts in pull_request_target/workflow_run unless allow-unsafe-pr-checkout is set, matching upstream actions/checkout - #65
Merged
Conversation
…llow-unsafe-pr-checkout is set Ports upstream actions/checkout's unsafe-pr-checkout-helper and its tests so a pull_request_target or workflow_run job cannot check out a fork's code with the base repository's secrets and token unless the step opts in, matching the guard upstream has shipped since v4.4.0 / v5.1.0. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
rcooney-sh
requested review from
adityamaru and
pbardea
and removed request for
aayushshah15 and
adityamaru
October 27, 2026 14:08
pbardea
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Feature —
useblacksmith/checkoutnow refuses to check out a fork pull request's code from apull_request_targetorworkflow_runworkflow unless the step setsallow-unsafe-pr-checkout: true, matching the guardactions/checkouthas shipped in every maintained major since v4.4.0 / v5.1.0. It does not change what the action checks out in any other event.Problem
pull_request_targetandworkflow_runjobs run with the base repository'sGITHUB_TOKEN, secrets, and cache scope even when the triggering PR comes from a fork. A workflow that then checks outgithub.event.pull_request.head.sha(orworkflow_run.head_sha) executes the fork's code with those secrets: the "pwn request" pattern. Upstreamactions/checkoutfails such a step before fetching anything. This action is a fork of upstream 5.0.0 and had no such check, so a workflow that swapsactions/checkout@v4foruseblacksmith/checkout@v1silently loses that protection.Fix
Port upstream's
src/unsafe-pr-checkout-helper.tsand its tests verbatim, and call it fromgetInputs:assertSafePrCheckoutthrows only when all of these hold: the event ispull_request_target, orworkflow_runwhose underlying event is apull_request*; the PR head repository id differs from the base repository id (a fork); and the requested checkout targets the fork repository, arefs/pull/N/{head,merge}ref, or the PR head / merge commit SHA. Same-repo PRs, the default self-checkout, base-branch refs, and unrelated third-party repositories pass through unchanged.src/unsafe-pr-checkout-helper.tsmain(import path adjusted for CommonJS)__test__/unsafe-pr-checkout-helper.test.tsunstable_mockModuleto this repo'slib/-based jest setupsrc/ref-helper.tsfromPayloadhelper the guard usessrc/git-source-settings.ts,src/input-helper.tsallowUnsafePrCheckoutsetting, parsed from the new input, guard call beforereturn resultaction.yml,README.mdallow-unsafe-pr-checkoutinput (defaultfalse), upstream's wordingdist/index.jsnpm run buildEvidence
npm run build,npm run lint, andnpx jestpass; the new suite covers fork head SHA, merge SHA,refs/pull/*refs, forkrepository:input, case-insensitive matching, the opt-in,workflow_runwithpull_requestandpull_request_targetunderlying events, and the same-repo / unrelated-repo / default-checkout allow paths.Risks
Verdict: Ship. The guard only fires for the event + fork + fork-ref combination upstream already rejects, and the error message names the opt-in.
Worry about: workflows that intentionally check out fork code in
pull_request_target/workflow_runjobs start failing at the checkout step withRefusing to check out fork pull request code ...until they addallow-unsafe-pr-checkout: true. That is the same break upstream users hit in July, and it is the point of the change.Checked, not worried: default self-checkout and
ref: ${{ github.sha }}/base.shapatterns (testsallows pull_request_target default checkout,allows ... unrelated third-party repo); same-repo PRs (head_repository.idequals base id); non-PRworkflow_runchains (workflow_run.eventnotpull_request*returns early); events other than the two named ones are untouched.If it goes wrong: a customer's
pull_request_target/workflow_runcheckout step fails with the message above; they either add the input or pin the previous release while we investigate; rollback is movingv1back to the previous tag.Release and moving the
v1tag are a separate step after review.Link to Devin session: https://app.devin.ai/sessions/79db4072e9c94658bfd784fd9acb22c9
Open in Devin Desktop: https://app.devin.ai/desktop/session/79db4072e9c94658bfd784fd9acb22c9?variant=devin
Requested by: @rcooney-sh
Need help on this PR? Tag
@codesmith-botwith what you need. (Staging)