fix(ci): make AI review safe + functional on fork PRs#6087
Merged
Conversation
The review job runs under pull_request_target (trusted context with the
Bedrock role + secrets). It was checking out the fork's head SHA, which
actions/checkout now refuses ('pwn request' guard) — so the workflow failed on
every fork PR (~90% of PRs), e.g. run 29965762436 on aws#6083.
Rework to the safe diff-only pattern (mirrors aws/*-agentcore pr-security-review):
- Check out the BASE repo, never fork head code — untrusted PR code is never
executed in the privileged job.
- Fetch the PR diff via the API into /tmp/pr.diff as read-only ground truth.
- Remove Bash from allowedTools; Claude reads the diff + uses Read/Grep/Glob
against the trusted base tree for context. Skip cleanly on empty diffs.
Does NOT use allow-unsafe-pr-checkout, which would expose secrets to fork code.
aviruthen
approved these changes
Jul 23, 2026
mohamedzeidan2021
approved these changes
Jul 23, 2026
mohamedzeidan2021
approved these changes
Jul 23, 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.
Problem
The AI Code Review workflow (added in #6053) fails on every fork PR — which is ~90% of PRs to this repo. Example: run 29965762436 on #6083 failed at checkout with:
The
reviewjob runs underpull_request_target(trusted context — it holds the Bedrock role and secrets) but was checking out the fork's head SHA.actions/checkoutblocks that by default because executing untrusted fork code in a trusted context is a vulnerability.Fix — safe diff-only review
Rather than opt into the unsafe checkout, this reworks the job so untrusted PR code is never executed in the privileged context (mirrors the pattern in AWS's own
*-agentcorepr-security-review.yml):base.sha), not the fork head. The trusted tree is used only for read-only context./tmp/pr.diff— data, not executable code.BashfromallowedTools. Claude reads the diff and usesRead/Grep/Globagainst the base tree; it cannot run commands or re-run git.Explicitly does not use
allow-unsafe-pr-checkout: true, which would expose secrets/the Bedrock role to fork-controlled code.Result