Syknapse / Syknapse/Contribute-To-This-Project
[BUG] Fix: Resolve checkout failure in auto-format workflow on fork PRs
@kuramaSeige-OFC is already working on this.
Since Aug 21, 2026.
- Dominant language
- JavaScript
- Stars
- 2.6k
- Forks
- 3.5k
- Avg merge
- 13h 14m
- Merged PRs (30d)
- 32
Description
Scenario & Narration
Our Auto Format workflow (auto-format.yml) runs on the pull_request_target trigger so it has the write access required to push formatting fixes back to fork branches.
However, recent runs on fork PRs are failing at the Checkout PR branch step with this error:
Error: Refusing to check out fork pull request code from a 'pull_request_target' workflow. ... Fetching and executing a fork's code in that trusted context commonly leads to "pwn request" vulnerabilities.
Here is why this occurs:
- In
pull_request_target, the workflow has access to write permissions and secrets (likeFORMAT_BOT_PAT). - Newer versions of
actions/checkout(v4/v6) block checking out code from a fork branch by default in privileged environments to protect the repository owner. - This blocks our format bot from ever running formatting on PRs from contributors.
Safety Analysis
Checking out a fork under pull_request_target is safe in our specific workflow because:
- We do not run
npm installor execute any scripts from the fork branch. - We overwrite the prettier config and
.prettierignorewith the trusted versions frommasterbefore executing Prettier. - We invoke Prettier solely via
npx.
Remediation Plan
We need to explicitly opt-in to checking out the fork code by adding allow-unsafe-pr-checkout: true to the checkout action block:
- name: Checkout PR branch
uses: actions/checkout@v6
with:
token: ${{ secrets.FORMAT_BOT_PAT }}
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
allow-unsafe-pr-checkout: true
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.