-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[StepSecurity] ci: Harden GitHub Actions #9356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[StepSecurity] ci: Harden GitHub Actions #9356
Conversation
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
📝 WalkthroughWalkthroughAdded explicit top-level Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
.github/workflows/maintenance-announce-pr.yml (1)
13-14:⚠️ Potential issue | 🟠 MajorMissing
contents: readat job level may break checkout.When job-level
permissionsare specified, they replace (not merge with) the top-level permissions. This job only declarespull-requests: read, so it won't havecontents: readpermission, which is required byactions/checkout@v6on Line 20.🔧 Proposed fix
permissions: + contents: read pull-requests: read.github/workflows/maintenance-label-on-approval.yml (1)
14-17:⚠️ Potential issue | 🟠 MajorAdd
actions: readpermission to the job's permissions block.The job downloads artifacts from an upstream workflow run using
run-id: ${{ github.event.workflow_run.id }}. GitHub Actions requires theactions: readpermission to access artifacts from different workflow runs, even when usingGITHUB_TOKEN. Without it, theactions/download-artifact@v7step will fail.Add the following to lines 14-17:
permissions: actions: read contents: read issues: write pull-requests: write
|
@coderabbitai |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain
By default, GitHub Actions workflows often have broader
Let me update the PR description to better reflect this security effect: 🏁 Script executed: Length of output: 512 Let me fix the script syntax: 🏁 Script executed: Length of output: 252
You're absolutely correct: the effect of these changes is to restrict permissions from the default (which can be read-write) to explicit read-only, following the principle of least privilege. By default, GitHub Actions workflows often have broader
I attempted to update the PR description to better reflect this security effect, but I'm unable to do so due to workflow restrictions on this repository. However, here's the improved description text that you or a maintainer can use to update it manually: This phrasing emphasizes the security effect (restricting permissions) rather than just the literal action (adding YAML blocks), as you suggested! |
Summary
This pull request is created by StepSecurity at the request of @iav. Please merge the Pull Request to incorporate the requested changes. Please tag @iav on your message if you have any questions related to the PR.
Security Fixes
Least Privileged GitHub Actions Token Permissions
The GITHUB_TOKEN is an automatically generated secret to make authenticated calls to the GitHub API. GitHub recommends setting minimum token permissions for the GITHUB_TOKEN.
Feedback
For bug reports, feature requests, and general feedback; please email support@stepsecurity.io. To create such PRs, please visit https://app.stepsecurity.io/securerepo.
Signed-off-by: StepSecurity Bot bot@stepsecurity.io
Summary by CodeRabbit
Security
Chores