-
Notifications
You must be signed in to change notification settings - Fork 3k
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
chore: Set permissions for GitHub actions #11226
Conversation
Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much. - Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) Signed-off-by: naveen <[email protected]>
permissions: | ||
contents: read |
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.
Is this necessary -- this is only on pull_request
, which does not get a token with write anyway?
I might have a gap in understanding here, so I'd appreciate context on why this exists.
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.
I agree it doesn’t get write token. It is best practice to set permissions.
That was my reasoning.
Thanks
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.
LGTM, but I do have one question (noted above)
As far as I understand, this would be mostly redundant as by default I suppose we could further restrict permissions by only granting read access to specific scopes. |
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.
I'm going to add the awaiting merge label to this PR as it would improve GHA security in depth. This isn't necessary, but it's unlikely to hurt either.
I'm not against rejecting this PR though.
(To fellow maintainers, the awaiting merge
label is brand new! It was created by Pradyun so I'd have a way to properly flag PRs that seem ready for merge, but don't belong in a release milestone.)
Ah, this branch is so old that the RTD build is failing. As long as the GHA CI passes, we can ignore that failure. |
Deja vu: #12564 (comment) |
I'm going to close this PR then. Also AFAIK, we also restrict the actions this repository workflows can use so we should be okay security-wise for now. |
Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests
Signed-off-by: naveen [email protected]