-
Notifications
You must be signed in to change notification settings - Fork 396
Set minimal workflow permissions #2772
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
Comments
I don't have a maintainer role either, and I also don't know who actually does -- I suspect @cmaureir does though. Otherwise we can ask in our Telegram group. I left a minor comment in the PR, but overall I'm pretty happy with the changes. Like I said in the PR, I'll follow suit in other projects I maintain, I definitely like having a more strict token by default and avoid security risks. |
Fixes #2772. This PR sets top-level read-only permissions on all CI/CD workflows. Jobs that require additional permissions (`stale.yml` and `pr-comment.yml`) are given them at the job-level. I made more significant changes in `pr-comment.yml`. It is vulnerable to code injection, since it runs files controlled by the PR author (`requirements.txt` and `scripts/list_missing_entries.py`, taken from the PR). I have therefore modified the workflow to checkout those files from the base branch instead, ensuring we're running trusted versions of those files. And in order to minimize the code that has access to the `issues/pull-requests: write` permissions, I have separated the workflow into two sequential jobs: 1. `define-comment`, which is unprivileged and does almost everything 2. `write-comment`, which has those additional permissions and uses them to perform the very last step of actually writing the comment on the PR. --------- Signed-off-by: Pedro Kaj Kjellerup Nacht <pnacht@google.com> Co-authored-by: rtobar <rtobarc@gmail.com>
Thanks for your contribution :)
This is now done 🎉 |
This repo's automated workflows currently run with write-all tokens. This puts the project at risk of supply-chain attacks. GitHub recommends ensuring all workflows run with minimal permissions.
I've taken a look at the workflows and they don't need such broad permissions.
This issue can be solved in two ways:
I'll be sending a PR along with this issue that sets the top-level permissions (and grants additional permissions for the jobs that need them). If you instead (or also) wish to modify the default token permissions:
Disclosure: My name is Pedro and I work with Google and the Open Source Security Foundation to improve the supply-chain security of important open-source projects.
The text was updated successfully, but these errors were encountered: