fix(ci): prevent untrusted review policy checkout - #904
Open
rl-block wants to merge 3 commits into
Open
Conversation
🔐 Codex Security Review
Review SummaryOverall Risk: NONE FindingsNo security, correctness, or reliability findings in the reviewed diff. NotesThe functional change pins privileged policy checkout to trusted Generated by Codex Security Review | |
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.
Reviewable diff: +3/-1 across 1 file (excludes generated, test, and story files).
Summary
Closes the critical untrusted-checkout path in the privileged Review Policy workflow. Pull-request metadata can no longer select the policy code that executes with elevated workflow access; the checkout is fixed to the repository's trusted
mainbranch.Related: CodeQL untrusted-checkout alert 79
How it works
The workflow still resolves the pull request's base and head SHAs for identity checks and diff construction. Those values are now used only by later explicit fetch and diff commands; the executable policy checkout always comes from
main, keeps credentials disabled, and retains full history for the three-dot diff.The regression test enumerates every
actions/checkoutstep in the privileged evaluation job. It requires exactly one checkout and verifies its literal ref, history depth, and credential settings, so a later PR-controlled checkout cannot silently replace the trusted workspace.flowchart LR A["Privileged review-policy event"] --> B["Checkout trusted main"] B --> C["Execute review policy"] D["PR base and head SHAs"] --> E["Fetch commits for diff only"] E --> F["Read-only classifier"] C --> FAreas of the code involved
.github/workflows/review-policy.ymlmain.github/scripts/evaluate_review_policy_test.pyKey technical decisions & trade-offs
maininstead of a PR-derived base SHA so the privileged checkout cannot be tainted and static analysis can prove the trust boundary.fetch-depth: 0because later three-dot diff construction requires repository history.repository:input; the checkout remains scoped to the current base repository.Testing & validation
python3 .github/scripts/evaluate_review_policy_test.py— 47 tests passed.git diff --check, pre-commit Ruff, and pre-push hooks passed.zizmorwas unavailable in the repository toolchain; GitHub CI is the authoritative workflow-security run.mainafter merge.Post-Deploy Monitoring & Validation
Review Policyrun; search logs forCheckout trusted base policyandUsing review policy code from the trusted base commit.main, policy evaluation stops before preflight, or alert 79 remains open after a fresh main scan. Revert this commit if Review Policy becomes unavailable; otherwise inspect the new CodeQL path before further changes.