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 #7728

Merged
merged 2 commits into from
Sep 28, 2022
Merged

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>
@cla-bot
Copy link

cla-bot bot commented Sep 24, 2022

Realm welcomes all contributions! The only requirement we have is that, like many other projects, we need to have a Contributor License Agreement (CLA) in place before we can accept any external code. Our own CLA is a modified version of the Apache Software Foundation’s CLA. Our records show that CLA has not been signed by @sashashura. Please submit your CLA electronically using our Google form so we can accept your submissions. After signing the CLA you can recheck this PR with a @cla-bot check comment. The GitHub usernames you file there will need to match that of your Pull Requests. If you have any questions or cannot file the CLA electronically, make a comment here and we will be happy to help you out.

@sashashura
Copy link
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla: yes label Sep 25, 2022
@cla-bot
Copy link

cla-bot bot commented Sep 25, 2022

The cla-bot has been summoned, and re-checked this pull request!

@fealebenpae
Copy link
Member

Hey @sashashura, thank you for the contribution!

It totally makes sense to assign the smallest needed permission set, but I am trying to understand the security implications of the change - since we don't use the pull_request_target trigger and require manual approvals for outside contributor PR workflows, the only other benefit I can think of is preventing third-party actions that receive the GITHUB_TOKEN secret in our own workflows to misuse it beyond its intended purpose, right?

@sashashura
Copy link
Contributor Author

sashashura commented Sep 26, 2022

Yes, the threat model in this case is a compromise of a building tool. Your case is a little more specific since you call only actions. There are other ways to protect from a compromised action, like hash pinning, but the general principle still applies - run program with least needed privileges (like do not run with sudo unnecessarily). An example of currently assigned permissions:
image

@fealebenpae fealebenpae merged commit 8ed5f3e into realm:master Sep 28, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants