ci: fix cache poisoning and least-privilege permissions#2392
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR hardens GitHub Actions CI/CD security by implementing event-aware cache handling for the build environment and applying least-privilege permissions across multiple workflows. The setup-build-environment action now prevents cache poisoning by gating cache writes to trusted events while providing read-only restore for untrusted PR events. ChangesGitHub CI/CD Security Hardening
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 actionlint (1.7.12).github/workflows/nexus-upload.yamlcould not read ".github/workflows/nexus-upload.yaml": open .github/workflows/nexus-upload.yaml: no such file or directory .github/workflows/pr-wip.yamlcould not read ".github/workflows/pr-wip.yaml": open .github/workflows/pr-wip.yaml: no such file or directory .github/workflows/maint-todo-issues.yamlcould not read ".github/workflows/maint-todo-issues.yaml": open .github/workflows/maint-todo-issues.yaml: no such file or directory 🔧 YAMLlint (1.38.0).github/actions/setup-build-environment/action.yaml[Errno 2] No such file or directory: '.github/actions/setup-build-environment/action.yaml' .github/workflows/pr-wip.yaml[Errno 2] No such file or directory: '.github/workflows/pr-wip.yaml' .github/workflows/maint-todo-issues.yaml[Errno 2] No such file or directory: '.github/workflows/maint-todo-issues.yaml'
🔧 zizmor (1.25.2).github/workflows/maint-todo-issues.yamlINFO zizmor: 🌈 zizmor v1.25.2 .github/workflows/nexus-upload.yamlINFO zizmor: 🌈 zizmor v1.25.2 .github/workflows/pr-wip.yamlINFO zizmor: 🌈 zizmor v1.25.2 🔧 Checkov (3.2.529).github/workflows/nexus-upload.yaml2026-05-21 10:33:19,814 [MainThread ] [ERROR] Template file not found: .github/workflows/nexus-upload.yaml ... [truncated 9182 characters] ... or directory: '.github/workflows/nexus-upload.yaml' .github/workflows/pr-wip.yaml2026-05-21 10:33:19,835 [MainThread ] [ERROR] Template file not found: .github/workflows/pr-wip.yaml ... [truncated 9080 characters] ... ning: could not process file .github/workflows/pr-wip.yaml .github/workflows/maint-todo-issues.yaml2026-05-21 10:33:19,811 [MainThread ] [ERROR] Template file not found: .github/workflows/maint-todo-issues.yaml ... [truncated 9267 characters] ... ory: '.github/workflows/maint-todo-issues.yaml'
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai explain this PR and say if there's any potential issues with it, or if its all good changes and no more work is required |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 7391
What the PR Does1. Cache Poisoning Fix (
|
| Workflow | Permissions Added | Reason |
|---|---|---|
maint-todo-issues.yaml |
contents: read, issues: write |
alstr/todo-to-issue-action needs to create issues from TODO comments |
nexus-upload.yaml |
contents: read |
Only reads releases via gh api / gh release download; writes only to Nexus via secrets |
pr-wip.yaml |
statuses: write, pull-requests: read |
wip/action@v1 reads PR title/labels and sets a commit status (uses the Statuses API, not Checks API) |
All three permission sets are correctly scoped — nothing is over- or under-granted.
Assessment
This PR is clean — no issues found. Specifically:
- ✅ The cache
if:conditions are correct (pull_requestandpull_request_targetboth excluded from writes) - ✅
actions/cache/restore@v5is the correct sub-action for restore-only behavior - ✅ Composite actions inherit
github.event_namefrom the caller workflow, so the conditions work as intended - ✅ All three permission blocks are minimal and match each workflow's actual access needs
- ✅ The changes are additive and don't alter any existing workflow logic
This directly addresses two CodeQL security findings (actions/cache-poisoning/poisonable-step and actions/missing-workflow-permissions) and follows well-established GitHub Actions hardening best practices. Safe to merge. 🐇
ci: harden cache trust and workflow permissions
Split actions/cache into trusted (restore+save) and untrusted
(restore-only) paths so PR builds cannot poison caches consumed
by default-branch runs. Addresses the CodeQL
actions/cache-poisoning/poisonable-step finding.
Add explicit least-privilege permissions blocks to three
workflows that previously inherited default write-all scope:
Addresses CodeQL actions/missing-workflow-permissions findings.
Lifted from alandtse fork
Summary by CodeRabbit