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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

naveensrinivasan
Copy link

 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>
@uranusjr uranusjr added the skip news Does not need a NEWS file entry (eg: trivial changes) label Jul 4, 2022
Comment on lines +7 to +8
permissions:
contents: read
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary -- this is only on pull_request, which does not get a token with write anyway?

I might have a gap in understanding here, so I'd appreciate context on why this exists.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it doesn’t get write token. It is best practice to set permissions.

That was my reasoning.

Thanks

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I do have one question (noted above)

@ichard26
Copy link
Member

ichard26 commented Apr 20, 2024

As far as I understand, this would be mostly redundant as by default GITHUB_TOKEN only provides read-only access to the repository thanks to current repository configuration: #12564 (comment)

I suppose we could further restrict permissions by only granting read access to specific scopes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news Does not need a NEWS file entry (eg: trivial changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants