Skip to content
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

GitHub Workflows security hardening #3377

Merged
merged 5 commits into from Sep 26, 2022
Merged

GitHub Workflows security hardening #3377

merged 5 commits into from Sep 26, 2022

Conversation

sashashura
Copy link
Contributor

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.

Signed-off-by: Alex <aleksandrosansan@gmail.com>
Signed-off-by: Alex <aleksandrosansan@gmail.com>
@lovell
Copy link
Owner

lovell commented Sep 20, 2022

Hello, thank you for the PR. As you may have noticed this repo is configured to always require manual approval before any workflow runs, but I'd be happy to strengthen this further, especially as this could help improve the security of forks.

The workflows require the ability to create releases and release artefacts, which I think means we'll also require the addition of contents: write at the job level.

@sashashura
Copy link
Contributor Author

Permissions are not as granular as they could be. contents: write covers all the cases you mentioned.

@sashashura
Copy link
Contributor Author

But currently I set contents to read. Do I understand correctly that

        env:
          prebuild_upload: ${{ secrets.GITHUB_TOKEN }}
        run: npx prebuild --runtime napi --target 7

creates GitHub release and needs the write permission?

@lovell
Copy link
Owner

lovell commented Sep 20, 2022

Yes, the prebuild step creates a release (if it doesn't already exist) with the same name as the tag and adds artefacts to that release.

Add the contents: write for npx prebuild
Add the contents: write for npx prebuild
@coveralls
Copy link

coveralls commented Sep 22, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling 7ed78f2 on sashashura:patch-1 into 70e6bb0 on lovell:main.

@sashashura
Copy link
Contributor Author

Just for the reference these are current permissions it runs with:
image

Copy link
Owner

@lovell lovell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, one more question inline otherwise this is good to go.

.github/workflows/ci.yml Show resolved Hide resolved
Style consistency
@lovell lovell merged commit 32a22b5 into lovell:main Sep 26, 2022
@lovell
Copy link
Owner

lovell commented Sep 26, 2022

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants