jupyterhub / team-compass

A repository for team interaction, syncing, and handling meeting notes across the JupyterHub ecosystem.
http://jupyterhub-team-compass.readthedocs.io
62 stars 33 forks source link

Reducing security risk in our GitHub workflows #404

Closed consideRatio closed 1 year ago

consideRatio commented 3 years ago

I've created this issue to coordinate security work across the org.

As initiated by @manics practically in https://github.com/jupyterhub/action-major-minor-tag-calculator/pull/75 and by the discussion in https://github.com/jupyterhub/team-compass/issues/398#issuecomment-823825014, we should do various things for our GitHub repos' GitHub workflows to improve the security posture against compromised GitHub actions.

Action points for each repo

In all GitHub workflows' jobs that are referencing a GitHub secret such as secrets.GITHUB_TOKEN or a manually configured such as secrets.DOCKERHUB_TOKEN, we should:

Non-archived repositories to consider

Has GHA in use

Doesn't have GHA in use, but have a need for tests/GHA

Doesn't have GHA in use, and have no need for it

Script to list repos of relevance

I used this script to get the names of repo's of relevance to create the lists above.

curl -H "Accept: application/vnd.github.v3+json"  "https://api.github.com/orgs/jupyterhub/repos?per_page=100" > tmp.json
cat tmp.json | jq '.[] | select(.archived == false) | .full_name'
minrk commented 3 years ago

More information in the github docs but there's also a degree of trust that informs how to do each pin:

  1. pinning sha means we don't need to trust the action repo (or github itself) to protect against malicious commits
  2. pinning tag means we trust the repo maintainer to protect their tags

The downside of 1. is that we need to update actions often, and especially means we won't get security updates if we don't stay on top of it (dependabot helps, I think?). So there can actually be a downside security-wise of pinning if it's the action itself that has a vulnerability (e.g. the codecov action contents had the vulnerability, the action repo itself was not compromised). For instance, I think it would be reasonable to trust @docker as much as @actions, but we can make that choice on a per-org or even per-action basis.

consideRatio commented 3 years ago

@minrk good points, then I suggest we trust @docker alongside @actions going onwards and raise discussions if there are other orgs and associated actions we want to trust or not.

consideRatio commented 3 years ago

dockerspawner, jupyter-remote-desktop-proxy, jupyter-server-proxy, jupyterhub-idle-culler: pypa/gh-action-pypi-publish@v1.4.1 / @v1.3.0 (latest is 1.4.2)

Feels okay for me to trust even though I would prefer we just do the terminal command ourselves directly to upload a package. Perhaps use @release/v1 which is a branch with the latest v1 releases instead of @v1.4.1 if we use the action?

Suggestion: we retain use of the pypa action, we trust it, and reference @release/v1 branch. Ok?

consideRatio commented 3 years ago

@sgibson91 @betatim @minrk what do you think about use of the following actions in mybinder.org-deploy's CD workflow jobs?

minrk commented 3 years ago

Suggestion: we retain use of the pypa action, we trust it, and reference @release/v1 branch. Ok?

Yeah, I think that's okay. It doesn't do much, so we could also do our own python -m build . && twine upload dist/* which works for ~all Python packages like you did for docker login.

consideRatio commented 3 years ago

Yeah, I think that's okay. It doesn't do much, so we could also do our own python -m build . && twine upload dist/* which works for ~all Python packages like you did for docker login.

In https://github.com/jupyterhub/sudospawner/pull/69/files#diff-87db21a973eed4fef5f32b267aa60fcee5cbdf03c67fafdc2a9b553bb0b15f34R23-R36 I've added a suggestion on the equivalent of using the PyPA action.

It is pretty much to run: twine check and twine upload, of which twine check now can be part of our test.

consideRatio commented 1 year ago

I don't think we should track this further than we have done by making the default permission for GITHUB_TOKEN that actions can access be contents:read in the entire jupyterhub org.