Skip to content

fix(ci): let AI code review run on external contributor PRs - #6185

Merged
jam-jee merged 1 commit into
aws:masterfrom
jam-jee:fix/ai-review-external-contributors
Aug 17, 2026
Merged

fix(ci): let AI code review run on external contributor PRs#6185
jam-jee merged 1 commit into
aws:masterfrom
jam-jee:fix/ai-review-external-contributors

Conversation

@jam-jee

@jam-jee jam-jee commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Issue

The AI code review workflow fails on every pull request from a fork, before any
review happens:

Checking permissions for actor: <author>
Permission level retrieved: read
[warning] Actor has insufficient permissions: read
[error] Action failed with error: Actor does not have write permissions to the repository

Example: run 31217496013 on #6166.

The collaborator gate, checkout, diff fetch and credential steps all succeed —
claude-code-action then runs its own actor permission check and exits. The net
effect is that the reviewer only ever ran for collaborators, and was a silent
no-op on external contributions.

Cause

claude-code-action requires the PR author to have write access. The check is
gated on the event being an "entity" context, which pull_request_target
satisfies, so it applies regardless of the action's mode. allowed_non_write_users
(which requires the github_token input this workflow already passes) is the
only 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 @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
review 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:

  • Deny reads on sensitive paths/proc, /sys, ~/.aws, the Actions
    _temp directory, and .git/config. The inline-comment tool is an output
    channel, so this closes the inject-then-exfiltrate-via-comment path. Verified:
    a /proc/self/environ read is blocked while ordinary file reads still work.
  • Prompt hardening — the model is told to treat all contributor-authored
    content strictly as data, never as instructions, and to report any attempted
    injection in its review summary.

Unchanged existing protections:

  • Fork PRs still require maintainer approval via the manual-approval
    environment.
  • No Bash, Write or Edit — the model cannot execute anything.
  • Checkout remains the trusted base repo; fork code is never executed.
  • The assumed role remains least-privilege: bedrock:InvokeModel on a single
    inference 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

  • Workflow YAML parses; new inputs resolve as expected.
  • --disallowedTools rule syntax validated against Claude Code: no
    unrecognized-rule warnings, /proc/self/environ denied, normal reads allowed.
  • As always with pull_request_target, the change only takes effect once merged
    to master, since the base-branch copy of the workflow is what runs.

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.
@jam-jee
jam-jee deployed to auto-approve August 14, 2026 20:23 — with GitHub Actions Active
@jam-jee
jam-jee merged commit b6eb059 into aws:master Aug 17, 2026
6 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.

2 participants