CI: check-docs fails on every fork PR — pull_request_target checkout blocked by actions/checkout fork guard
Symptom
The check-docs job (.github/workflows/claude-docs-check.yml) fails about 6 seconds into the run on fork-based PRs, at the checkout step — before any documentation analysis runs. The Read the Docs build itself succeeds, so this is purely a workflow-configuration issue, not a content/docs problem.
Reproducible on multiple unrelated fork PRs:
The job logs:
##[error]Refusing to check out fork pull request code from a 'pull_request_target' workflow.
This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch
cache scope, and runner access. Fetching and executing a fork's code in that trusted
context commonly leads to "pwn request" vulnerabilities. To opt in, review the risks
at https://gh.io/securely-using-pull_request_target and set
'allow-unsafe-pr-checkout: true' on the actions/checkout step.
Root cause
The workflow triggers on pull_request_target (so it runs with the base repository's token and secrets), but its Checkout repository step explicitly checks out the fork's head commit:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
Current actions/checkout@v4 refuses exactly this combination — untrusted fork code inside a privileged pull_request_target context — unless allow-unsafe-pr-checkout: true is set.
For context, #2606 previously fixed a different fork failure in this same job (the claude-code-action "Actor does not have write permissions" error) by adding allowed_non_write_users: "*", which is present. That fix is correct but orthogonal: the run now trips the checkout guard before the action is ever reached.
Impact
Every external (fork) PR touching src/**/*.py gets a red check-docs check regardless of its content, which is noise for both contributors and reviewers and can mask genuinely required reviews.
Suggested fixes
Option 1 — Quick (opt into the checkout): add allow-unsafe-pr-checkout: true to the checkout step. This is the smallest change, but it deliberately re-enables the "pwn request" path. The job is read-only in intent, yet it currently grants pull-requests: write, issues: write, and id-token: write, and claude-code-action reads repository instructions (e.g. CLAUDE.md) from the checked-out tree — so untrusted fork code in this context is a real attack surface. If you go this route, I'd also suggest trimming permissions: to the minimum (the action only needs to post a PR comment/label — likely just pull-requests: write, dropping issues: write and id-token: write).
Option 2 — Safer (recommended): keep the privileged pull_request_target job from checking out fork code at all. Run on the base checkout and obtain the diff via gh pr diff <number> (the action's prompt already instructs it to do this), or split into two jobs: an unprivileged pull_request job that performs the analysis, and a pull_request_target job that only posts the resulting comment/label.
Note: because this is a
pull_request_targetworkflow, edits to it from a fork PR do not take effect until they land on the default branch, so this needs a maintainer-side merge/push (a fork PR can't validate the fix on its own CI).
Related
- #2692 ([Security] Agentic Workflow Injection in Claude Docs Check) and #2666 ([Security] Security issue in your GitHub CI workflow YAML files) report the security side of this same workflow — running untrusted fork code in a privileged
pull_request_targetcontext. The hard failure described here is essentially the checkout guard now enforcing exactly that risk: the current guard makes the job red on every fork PR, and the safer remediation (Option 2, not checking out fork code in the privileged job) addresses both the injection risk and this breakage together.
Happy to open a PR with whichever approach you prefer.
Two places, not one.
I re-ran a census over vibrantlabsai/ragas@298b68274234c060deacab3cf5fb52aa3a20e885 (main, after #2606) before writing this, and the pattern is in two workflows, not one:
| workflow | declares pull_request_target |
checks out PR-head code |
|---|---|---|
claude-docs-check.yml |
:4 |
:22-23 — head.repo.full_name + head.sha |
claude-docs-apply.yml |
:4 |
:21-22 — head.repo.full_name + head.ref |
issue-manager.yaml |
:13 |
no — reads the event payload only |
Eight workflow files total, three declare pull_request_target, two check out fork code. apply.yml is the one I would worry about more: permissions: contents: write at :12 and secrets.CLAUDE_CODE_PAT || secrets.GITHUB_TOKEN at :24, on a workflow whose whole purpose is to write into the checked-out tree.
Right now it is unreachable because check.yml goes red first: the checkout dies before the step that adds needs-doc-update, and that label is the only trigger of apply.yml. Measured: Claude Docs Apply (workflow id 216244931) has total_count: 0 runs, ever. So option 2 applied only to check.yml would leave a contents: write workflow checking out fork code the moment the label side starts working.
Option 1 has a version floor that is easy to miss
allow-unsafe-pr-checkout does not exist in actions/checkout v4.1.7, v4.2.0, v4.2.1, v4.2.2, v4.3.0 or v4.3.1. It first appears in v4.4.0 (action.yml:101). Unknown action inputs are ignored silently, so a repo that pins @v4.3.1 or lower — a reasonable thing to do while hardening — would keep the workflow broken with no error pointing at the input. All eight workflow files here pin @v4 (floating) or @v3; the floating v4 tag currently resolves to 11d5960a326750d5838078e36cf38b85af677262, which is exactly v4.4.0.
When it started, and why the date looks arbitrary
Claude Docs Check(216244933), 391 runs total, all from forks: 142 success, 223 failure, 26 cancelled.- Last success:
2026-07-20T11:26:10Z. First failure of the current streak:2026-07-20T16:54:58Z. 162 consecutive failures, zero successes since. actions/checkoutv4.4.0was published2026-07-20T15:36:10Z— 78 minutes before the first failure of the streak. Nobody edited the workflow that afternoon; the floatingv4tag moved under it.- Monthly 2026: Jan 11F/12S · Feb 18F/6C · Mar 6F/20C · Apr 3F/17S · May 1F/33S · Jun 5F/30S · Jul 23F/36S · Aug 57F/0S · Sep 46F/0S · Oct 27F/0S · Nov 9F/0S.
One honesty note on the evidence: run logs older than roughly 2026-08-08 are expired (HTTP 410, verified on 29761604518, 29969743820, 30172312325, 30699126261), so I cannot show the log of the first failure of the streak. The oldest post-boundary run with a readable log is 31348988198 (2026-08-10), and it fails with:
allow-unsafe-pr-checkout: false
##[error]Refusing to check out fork pull request code from a 'pull_request_target' workflow
The same message appears in the two runs cited above (33152649500, 31957887691) and in 41895121612, 41809904159, 41808829996. So: cause NO_MEDIDO for the first failure of the streak, cause measured (this checkout guard) for every failure I can actually read.
If it helps, I can send the bisect as a table against action.yml for each tag — it is the part that decides whether option 1 is safe to pin.
— @alexisromtz-lab
All of the above is pinned to 298b68274234c060deacab3cf5fb52aa3a20e885, not to main.