fix(ci): let AI code review run on external contributor PRs - #6185
Merged
Conversation
The reviewer aborted on every fork PR with "Actor does not have write permissions to the repository" (e.g. run 31217496013 on aws#6166), so it only ever ran for collaborators. claude-code-action checks that the PR author has write access before doing anything. That default protects its normal @claude usage, where a read-only user's comment becomes the prompt. It does not apply here: pull_request_target always runs the base-branch copy of this workflow, so the prompt is fixed by maintainers and a fork cannot supply it. Set allowed_non_write_users so the review actually runs, and harden the prompt-injection surface it exposes (untrusted diff/PR text entering context): - deny Read on /proc, /sys, ~/.aws, the Actions _temp dir and .git/config so an injected instruction cannot use the review comment as a secret-exfiltration channel - instruct the model to treat all contributor-authored content as data, never as instructions, and to report attempted injection Fork PRs continue to require maintainer approval via the manual-approval environment, Bash/Write/Edit remain unavailable, and the assumed role is still limited to bedrock:InvokeModel on a single inference profile.
rsareddy0329
approved these changes
Aug 14, 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.
Issue
The AI code review workflow fails on every pull request from a fork, before any
review happens:
Example: run 31217496013 on #6166.
The collaborator gate, checkout, diff fetch and credential steps all succeed —
claude-code-actionthen runs its own actor permission check and exits. The neteffect is that the reviewer only ever ran for collaborators, and was a silent
no-op on external contributions.
Cause
claude-code-actionrequires the PR author to havewriteaccess. The check isgated on the event being an "entity" context, which
pull_request_targetsatisfies, so it applies regardless of the action's
mode.allowed_non_write_users(which requires the
github_tokeninput this workflow already passes) is theonly supported way to run the action for read-access authors.
Change
Set
allowed_non_write_users: "*", plus compensating controls.That default exists to protect the action's normal
@claudeusage, where aread-only user's comment becomes the prompt. It does not apply here:
pull_request_targetalways runs the base-branch copy of this workflow, so thereview prompt is fixed by maintainers and cannot be supplied by a fork.
What contributors can influence is the content the model reads — the diff, code
comments, commit messages, and the PR title/body/comments. That is a
prompt-injection surface, so this PR also narrows the blast radius:
/proc,/sys,~/.aws, the Actions_tempdirectory, and.git/config. The inline-comment tool is an outputchannel, so this closes the inject-then-exfiltrate-via-comment path. Verified:
a
/proc/self/environread is blocked while ordinary file reads still work.content strictly as data, never as instructions, and to report any attempted
injection in its review summary.
Unchanged existing protections:
manual-approvalenvironment.
Bash,WriteorEdit— the model cannot execute anything.bedrock:InvokeModelon a singleinference profile, 1 hour max session.
Residual risk
Worst case under a successful injection is disclosure of a short-lived session
token whose only permission is invoking one Bedrock model — i.e. token spend, not
data or infrastructure access.
Testing
--disallowedToolsrule syntax validated against Claude Code: nounrecognized-rule warnings,
/proc/self/environdenied, normal reads allowed.pull_request_target, the change only takes effect once mergedto
master, since the base-branch copy of the workflow is what runs.