fix(security): replace pull_request_target with pull_request trigger#328
Conversation
Replace vulnerable pull_request_target workflow with secure pull_request trigger to prevent prompt injection attacks from fork PRs. Changes: - Replace pr-review-auto-fix.yml with pr-review.yml - Use pull_request trigger (not pull_request_target) - Add explicit PR number in prompt to fix wrong-PR bug - Skip fork PRs by design (security measure) - Update AUTOMATED_REVIEW.md documentation Fork PRs no longer receive automated reviews. Contributors should push to username/branch in the main repo instead of using forks. Fixes: RHOAIENG-51622 Fixes: ambient-code#324 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📈 Test Coverage Report
Coverage calculated from unit tests only |
Outdated review (click to expand)AgentReady Code ReviewPR: #328 — fix(security): replace pull_request_target with pull_request trigger Summary
Score Impact: Neutral to slight positive — security hardening with acceptable trade-off on fork PR coverage. ✅ What's Done WellCritical Security Fix — The core change is correct and important. Fork filtering via if: github.event.pull_request.head.repo.full_name == github.repositoryThis explicit guard correctly skips fork PRs and fails cleanly with a clear reason, rather than silently failing due to missing secrets. This is good defensive coding. Explicit PR number in prompt prompt: |
Run the /review-agentready command on pull request #${{ github.event.pull_request.number }}.
...
Post the review as a comment on PR #${{ github.event.pull_request.number }}.Good fix for the wrong-PR bug. Grounding the prompt with an explicit PR number eliminates ambiguity when
Correct cleanup — this option was compensating for a security limitation that no longer exists with the new approach. 🔴 Issues to Address1.
|
| Finding | Attribute | Tier | Impact |
|---|---|---|---|
contents: write overly broad |
3.1 Security Best Practices | 3 | −2 pts |
| Actionlint not run | 2.9 CI/CD Best Practices | 2 | −1 pt |
| Stale documentation | 1.2 README/Documentation | 1 | −1 pt |
Net assessment: The security benefit of this PR outweighs the minor issues. Once contents: write is narrowed and actionlint passes, this is merge-ready.
Recommended Changes Before Merge
- Change
contents: write→contents: readin workflow permissions - Run
actionlint .github/workflows/pr-review.ymland fix any findings - Update the Customization section in
AUTOMATED_REVIEW.md(replacepr-review-auto-fix.ymlwithpr-review.yml) - Remove or archive the "Auto-Fix Not Running" and "Fixes Causing Test Failures" troubleshooting sections
🤖 Generated with Claude Code via /review-agentready
- Change permissions from contents: write to contents: read (least privilege) - Remove private JIRA reference from workflow comments - Remove stale auto-fix customization section from docs - Remove stale auto-fix troubleshooting sections from docs - Verified with actionlint (no errors) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 AgentReady Code ReviewPR Status: 2 issues found (0 🔴 Critical, 1 🟡 Major, 1 🔵 Minor) ✅ Security Improvements VerifiedThis PR correctly addresses a critical
These changes are correct and well-implemented. 🟡 Major Issues (Confidence 80-89) — Manual Review Required1. Actionlint validation not confirmedAttribute: CI/CD Workflow Quality (Tier 3: Important) Issue Details:
No evidence of actionlint validation in the PR. The workflow YAML structure appears valid, but this is a mandatory step per project guidelines. Remediation: # Install actionlint if not present
brew install actionlint # or: go install github.com/rhysd/actionlint/cmd/actionlint@latest
# Validate the workflow
actionlint .github/workflows/pr-review.yml🔵 Minor Issues (Confidence 80) — Optional2. Private JIRA reference inaccessible to external contributorsAttribute: Documentation Quality (Tier 1: Essential) Issue Details: # Current (private):
# Security: RHOAIENG-51622
# Suggested (public reference):
# Security: Prevents prompt injection attacks (see #324)Remediation: # Replace private JIRA reference with public GitHub issue
sed -i 's/RHOAIENG-51622/GitHub #324/' .github/workflows/pr-review.ymlℹ️ Informational NotesCheckout
Summary
This is a well-executed security fix. The core changes are correct, targeted, and address a real vulnerability. The actionlint check is the primary blocker per CLAUDE.md requirements. 🤖 Generated with Claude Code If this review was useful, react with 👍. Otherwise, react with 👎. |
|
🎉 This PR is included in version 2.29.5 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
pull_request_targettrigger with securepull_requesttriggerFixes
Root Cause
The
pr-review-auto-fix.ymlworkflow usedpull_request_targettrigger, which:Changes
.github/workflows/pr-review.ymlpull_requesttrigger.github/workflows/pr-review-auto-fix.yml.github/AUTOMATED_REVIEW.mdTrade-off
Fork PRs no longer receive automated reviews. Contributors should push to
username/branchin the main repo instead.Test Plan
After merge:
PR Reviewworkflow triggersCo-Authored-By: Claude Opus 4.5 noreply@anthropic.com