Harden CI AI review execution#14796
Open
xingbowang wants to merge 1 commit into
Open
Conversation
T272955643 identified that fork PR content is passed into AI review prompts while the Codex path previously ran with `--dangerously-bypass-approvals-and-sandbox`. Keep fork PR reviews enabled, but remove that unsafe execution mode from the shared analysis workflow. Run every Codex classifier, review, query, and recovery invocation non-interactively with `--ask-for-approval never --sandbox read-only` instead. This keeps CI from blocking on approvals while preventing model-driven shell commands from writing to the workspace, and it filters `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, and `GITHUB_TOKEN` out of the shell environment inherited by those commands. Also remove `Write` and `Task` from the main Claude review calls. Claude still has read-only repository tools for analysis, but prompt-injected PR content no longer gets a direct path to modify checkout files that later `github-script` steps execute. Test Plan: `git diff --check` `make check-workflow-yaml` `make check-sources` `codex --ask-for-approval never --sandbox read-only exec review --help`
✅ clang-tidy: No findings on changed linesCompleted in 0.0s. |
🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit a5da299 ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit a5da299 SummaryGood security hardening PR that replaces the dangerous High-severity findings (0): No high-severity findings. Full review (click to expand)Findings🔴 HIGHNone. 🟡 MEDIUMM1. Verify
|
| Component | Impact | Status |
|---|---|---|
| Claude primary review flow | No impact — output via execution log | Safe |
| Claude max-turns recovery | Degraded — falls back to raw text extraction | Acceptable |
| Codex primary review flow | Depends on sandbox scope for --output-last-message |
Needs verification |
| Codex recovery flow | Same sandbox dependency | Needs verification |
| Comment builder (Claude) | No impact — reads execution log | Safe |
| Comment builder (Codex) | Falls back to log tail if output file missing | Graceful degradation |
| Comment poster workflow | No impact — reads uploaded artifact | Safe |
| Secret filtering | Effective with inherit="core" as primary control |
Good |
Positive Observations
- Replacing
--dangerously-bypass-approvals-and-sandboxwith specific controls is a significant security improvement. The flag name itself indicates it was never intended for production use. - The
shell_environment_policy.inherit="core"+ explicitexcludelist provides layered defense against secret leakage. - YAML injection prevention is properly maintained throughout (user inputs via
env:blocks, not inline${{ }}). - The permission model (
contents: read,actions: read,checks: read,pull-requests: read) follows principle of least privilege. - All 8 Codex invocations are consistently updated — no invocations were missed.
- The security comment accurately describes the new posture.
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
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.
Summary
--ask-for-approval never --sandbox read-onlyinstead of--dangerously-bypass-approvals-and-sandbox.OPENAI_API_KEY,ANTHROPIC_API_KEY, andGITHUB_TOKENout of shell environments inherited by Codex-managed commands.WriteandTaskfrom Claude reviewallowed_toolswhile retaining read-only repository inspection tools.Test Plan
git diff --check upstream/main...2026_05_27_codex_reviewmake check-workflow-yamlmake check-sourcescodex --ask-for-approval never --sandbox read-only exec review --help