terminal icon indicating copy to clipboard operation
terminal copied to clipboard

GitHub Workflows security hardening

Open sashashura opened this issue 2 years ago • 5 comments

This PR adds explicit permissions section to workflows. This is a security best practice because by default workflows run with extended set of permissions (except from on: pull_request from external forks). By specifying any permission explicitly all others are set to none. By using the principle of least privilege the damage a compromised workflow can do (because of an injection or compromised third party tool or action) is restricted.

It is recommended to have most strict permissions on the top level and grant write permissions on job level case by case.

sashashura avatar Dec 08 '22 17:12 sashashura

Since this job does write to the project board, do we need to add these permissions to the job object?:

permissions:
    repository-projects: write

DHowett avatar Dec 16 '22 22:12 DHowett

It looks like the answer is no, because (1) it doesn't target repository projects and (2) we do have an explicit PAT assigned for it to do its work organization-wide.

DHowett avatar Dec 16 '22 22:12 DHowett

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

ghost avatar Dec 16 '22 22:12 ghost

Apologies, I am afraid I am encountering technical difficulties that might have hampered my ability to assist with merging this pull request. I will continue to try to assist if there are further changes to this pull request.

ghost avatar Dec 16 '22 22:12 ghost

It looks like the answer is no, because (1) it doesn't target repository projects and (2) we do have an explicit PAT assigned for it to do its work organization-wide.

Yes, the permission is not needed because you use a dedicated PAT for this and the permissions sections affects only the automatically generated temporary GITHUB_TOKEN. Although it is not used it is accessible and quite powerful, so it is better set it's permissions to none.

sashashura avatar Dec 17 '22 21:12 sashashura