Skip to content

Fix claude-code-review.yml: trust-gate check + restore persist-credentials: false - #33

Merged
jnasbyupgrade merged 3 commits into
masterfrom
fix-claude-review-trust-gate
Aug 8, 2026
Merged

Fix claude-code-review.yml: trust-gate check + restore persist-credentials: false#33
jnasbyupgrade merged 3 commits into
masterfrom
fix-claude-review-trust-gate

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The claude-review job's trust gate checked:

github.event.pull_request.head.repo.owner.login == 'jnasbyupgrade'

head.repo.owner.login only distinguishes "who owns the fork" for fork-headed PRs. For an upstream-branch-headed PR (base and head both live in this repo -- required by gh stack, and also just what you get from gh pr create without a fork), head.repo.owner.login is always this repo's own org, never the actual PR author. The gate silently skipped review on every such PR regardless of who opened it.

Confirmed via a real case where claude-review showed conclusion: "skipped" on a whole PR stack that was legitimately jnasbyupgrade's own work, opened as upstream-branch PRs (needed for gh stack to link them).

Fix: check PR author instead:

github.event.pull_request.user.login == 'jnasbyupgrade'

PR author can't be spoofed by a third party any more than head repo owner can, and it's the more direct question for this gate's purpose (trusting the person asking for review, not the repository their branch happens to live in). Works for both fork-headed and upstream-branch-headed PRs.

This repo had a loud "SECURITY-CRITICAL, don't weaken this check" comment directly above the condition, added because this check is the entire security boundary once pull_request_target and a write-capable token are in play. Kept the comment, updated it to describe user.login (the correct, still-load-bearing check) instead of the old head.repo.owner.login field.

Postgres-Extensions/pg_count_nulls already uses this correct pattern.

Also folded in (was #38, closed as superseded by this PR)

The fork-checkout fix (removing the repository:/ref: override so this step checks out the base branch instead of an untrusted PR ref) was applied by deleting the whole with: block under actions/checkout, which also silently dropped persist-credentials: false. This job's permissions include pull-requests: write, a real write-capable credential; nothing here legitimately runs git push (review comments post via the API/claude-code-action, not git), so there's no reason to leave that credential sitting in .git/config for the rest of the job to misuse if anything later goes wrong.

… owner

head.repo.owner.login only identifies the fork owner for fork-headed PRs.
For an upstream-branch-headed PR (base and head both in this repo, as
required by gh stack or produced by a plain gh pr create without a fork),
it's always this repo's own org, never the actual PR author -- so the gate
silently skipped review on every such PR regardless of who opened it.

Switch to github.event.pull_request.user.login, which is the PR's actual
author and can't be spoofed any more than head repo owner can, and covers
both fork-headed and upstream-branch-headed PRs correctly. Also updates the
SECURITY-CRITICAL comment above the condition so it references the new
field instead of describing the old, now-wrong one.
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bd46ce62-333b-40cb-b3fe-388ee37a4a68

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…eckout step

The fork-checkout fix (removing the repository:/ref: override so this step
checks out the base branch instead of an untrusted PR ref) was applied by
deleting the whole with: block under actions/checkout, which also silently
dropped persist-credentials: false. This job's permissions include
pull-requests: write, a real write-capable credential; nothing here
legitimately runs git push (review comments post via the API/
claude-code-action, not git), so there's no reason to leave that credential
sitting in .git/config for the rest of the job to misuse if anything later
goes wrong.
@jnasbyupgrade jnasbyupgrade changed the title Fix claude-code-review.yml trust gate: check PR author, not head repo owner Fix claude-code-review.yml: trust-gate check + restore persist-credentials: false Aug 8, 2026
@jnasbyupgrade
jnasbyupgrade merged commit 23ba3f9 into master Aug 8, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant