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

chore: Set permissions for GitHub actions #12462

Merged
merged 1 commit into from Mar 29, 2023

Conversation

naveensrinivasan
Copy link
Contributor

 Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
@normanmaurer normanmaurer merged commit ccc5e01 into netty:4.1 Mar 29, 2023
@normanmaurer
Copy link
Member

@naveensrinivasan thanks a lot and sorry for the delay.

@normanmaurer normanmaurer added this to the 4.1.91.Final milestone Mar 29, 2023
normanmaurer pushed a commit that referenced this pull request Mar 29, 2023
Motivation:

Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

Modifications:

- Included permissions for the action. 
  https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions
  https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
  https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

Result:

Secure GitHub actions

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
@naveensrinivasan naveensrinivasan deleted the Pinned-Dependencies-GitHub branch March 29, 2023 13:52
normanmaurer pushed a commit that referenced this pull request May 22, 2023
Motivation:

Setting minimum permissions on workflow's top level is good practice.
Similar changes were previously discussed in
#12462. Since some workflows were
left out of the previous PR, this PR is a small update to restrict their
permissions.

Modification:

Set top level read only permission to `ci-deploy.yml`, `ci-pr.yml`,
`ci-release.yml` and `ci-release5.yml`

I wasn't able to test the workflows:

- `ci-release.yml` and `ci-release5.yml`: although I wasn't able to test
successfully, considering that they are basically using personalized
secrets and not the standard GITHUB_TOKEN (github.token), I've
considered that no write permission would be needed to it. To avoid
errors I've opted for `read-all` instead of `contents: read`.

- `ci-deploy.yml` also seems to not be working so I wasn't able to
provide a success example either.

- `ci-pr.yml` run example
https://github.com/joycebrum/netty/actions/runs/4994205584. Not sure why
it didn't run on my fork but the errors seems not to be related to any
permission. Anyway, I've changed the permission to read-all which
certainly will be enough since it runs on pull request (which will
always be no more than read-all to external PRs).

Result:

Similar change discussed at #12462:
since github workflow default behavior is to grant write all permission
to any workflow it is both a recommendation from [OpenSSF
Scorecard](https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions)
and the
[Github](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions)
to always use credentials that are minimally scoped.

---------

Signed-off-by: Joyce <joycebrum@google.com>
normanmaurer pushed a commit that referenced this pull request May 22, 2023
Motivation:

Setting minimum permissions on workflow's top level is good practice.
Similar changes were previously discussed in
#12462. Since some workflows were
left out of the previous PR, this PR is a small update to restrict their
permissions.

Modification:

Set top level read only permission to `ci-deploy.yml`, `ci-pr.yml`,
`ci-release.yml` and `ci-release5.yml`

I wasn't able to test the workflows:

- `ci-release.yml` and `ci-release5.yml`: although I wasn't able to test
successfully, considering that they are basically using personalized
secrets and not the standard GITHUB_TOKEN (github.token), I've
considered that no write permission would be needed to it. To avoid
errors I've opted for `read-all` instead of `contents: read`.

- `ci-deploy.yml` also seems to not be working so I wasn't able to
provide a success example either.

- `ci-pr.yml` run example
https://github.com/joycebrum/netty/actions/runs/4994205584. Not sure why
it didn't run on my fork but the errors seems not to be related to any
permission. Anyway, I've changed the permission to read-all which
certainly will be enough since it runs on pull request (which will
always be no more than read-all to external PRs).

Result:

Similar change discussed at #12462:
since github workflow default behavior is to grant write all permission
to any workflow it is both a recommendation from [OpenSSF
Scorecard](https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions)
and the
[Github](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions)
to always use credentials that are minimally scoped.

---------

Signed-off-by: Joyce <joycebrum@google.com>
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

2 participants