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

Harden security of GitHub Actions CI/CD #200

Closed
1 task done
brycx opened this issue May 4, 2021 · 7 comments · Fixed by #202 or #232
Closed
1 task done

Harden security of GitHub Actions CI/CD #200

brycx opened this issue May 4, 2021 · 7 comments · Fixed by #202 or #232
Assignees
Labels
investigation Investigation task security Security-related issues or improvements
Milestone

Comments

@brycx
Copy link
Member

brycx commented May 4, 2021

Brian Smith has done some pretty interesting investigations into the default security of GitHub Actions at briansmith/untrusted#50 and how to harden these. I'd like for us to re-trace some (if not all) of the steps there and see which can be implemented for our CI/CD.

I was surprised to see that default permissions for GitHub Actions are read+write for a repository. We should be able to change this to read-only without breaking the current CI/CD.

The official GitHub documentation for this: https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions

Eg. setting read-only for an Action:

name: action

permissions:
  contents: read

TODO:

  • Delete the stored token once the changes are applied and if it's not used anymore
@brycx brycx added security Security-related issues or improvements dependencies Issues or improvements related to used dependencies investigation Investigation task and removed dependencies Issues or improvements related to used dependencies labels May 4, 2021
@vlmutolo
Copy link
Contributor

vlmutolo commented May 17, 2021

Just recording a tentative todo list here:

  • Make GitHub token read-only
  • Pin actions by their sha1 hash (ideal) or by their git version tags
    • Maybe we should fail CI tests if the sha1 hash doesn't match that of the latest release
  • Try to remove codecov token entirely

@vlmutolo
Copy link
Contributor

So I'm thinking that it's probably going overboard to fail CI if there's a new release in one of our actions. We only really care if there's a new release when there's a security vulnerability. For Rust dependencies, we rely on cargo-audit, but I'm not sure if there's something similar we can do for our actions.

Thoughts?

@vlmutolo vlmutolo linked a pull request May 17, 2021 that will close this issue
@brycx
Copy link
Member Author

brycx commented May 27, 2021

Yeah, failing CI seems a bit overboard.

I've found the following docs: https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/keeping-your-actions-up-to-date-with-dependabot#enabling-dependabot-version-updates-for-actions

So we should actually be able to easily check for updates to the actions via. Dependabot. We simply have to add the additional parameters to the dependabot.yml file. This way we won't fail the CI, but instead receive PRs from Dependabot like with our other dependencies. The way I read the introduction, it should also be able to check for actions pinned by commit hashes.

Seems like a good approach, anything I'm missing?

@brycx
Copy link
Member Author

brycx commented May 27, 2021

Also, nice with the added todo-list, for things that can't really be tracked with commits.

@vlmutolo
Copy link
Contributor

I'll read up on dependabot. Seems like a good solution.

@brycx
Copy link
Member Author

brycx commented May 28, 2021

Try to remove codecov token entirely

We'll have to remember to delete the stored token once the changes are applied and it's not used at all anymore.

@brycx brycx added this to the v0.16.1 milestone Jun 15, 2021
@brycx
Copy link
Member Author

brycx commented Oct 23, 2021

Re-opening due to remaining TODO and PR #232

@brycx brycx reopened this Oct 23, 2021
@brycx brycx linked a pull request Oct 23, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation Investigation task security Security-related issues or improvements
Projects
None yet
2 participants