Tighten up the GitHub Actions workflow permissions#1048
Tighten up the GitHub Actions workflow permissions#1048johnbillion wants to merge 2 commits intodevelopfrom
Conversation
|
@johnbillion Thank you for this PR. I've looked into adding these permissions before, but got stuck on insufficient documentation being available on when which permission is needed. Would you mind explaining how you determined the needed permission for these actions now ? An example of something which I never really got clarity on, is whether jobs which post an annotation to a PR with feedback need additional permissions or not. Another thing - as far as I understand it, it is a common best practice to document the permissions added for each job with a small comment. This is also encouraged by tools like zizmor. Is there any particular reason that best practice is not being applied ? |
Yeah we got caught on this when tightening up the wordpress-develop and gutenberg repos last year. There isn't any documentation that allows you to easily correlate existing workflow jobs with the permissions that they require. We went too tight on a few jobs in gutenberg and had to loosen the permissions after the job failed with a permissions error.
All the jobs with just The general approach to determining permissions is to go through each step in each job and identify whether it interacts with a GitHub service, for example by calling a GitHub API endpoint directly, using the
This doesn't need any permission, because annotations come directly from the output in the workflow run log.
No reason, which is ironic because I was the person who added that audit to Zizmor. I've just pushed a commit that adds inline comments! |
This change uses the principal of least privilege to tighten up the permissions that are granted to the
GITHUB_TOKENaccess tokens that get granted and used during GitHub Actions workflow runs.This minimises the impact that a token leak can have and allows the "Workflow permissions" setting on https://github.com/WordPress/Requests/settings/actions to be switched to read-only from its current read and write setting.
Further reading:
Pull Request Type
This is a:
Context
The security team are working on publishing full guidance, standards, and tools for GitHub Actions workflow hardening across the WordPress organisation on GitHub. This is a hardening measure while that's all being worked on.