Skip to content

Set minimal scoped permissions to github workflows #348

Closed

Description

@joycebrum

I would like to suggest to getrandom project to set minimal scoped permissions to its github workflows (in this case the tests.yml file). This means setting the permissions as read only on the top level and any write permission be given at the run level.

This is necessary due to a behavior of github workflow to grant to GITHUB_TOKEN write permissions to all types of permissions, regardless of they being used or not. In case of the workflow getting compromised, an attacker can exploit this permissions.

This can be seen in the Action run step "Set up job" such as https://github.com/rust-random/getrandom/actions/runs/4412157849/jobs/7731354938.

image

Let me know if a PR is welcome with the changes mentioned above.
Thanks!

Disclosure: I'm from Google working with the OpenSSF to improve supply-chain security in many open source projects.

Activity

  1. newpavlov commented on Mar 18, 2023

    @newpavlov
    Member

    Yes, having minimal permissions is preferable, so feel free submit a PR!

  2. josephlr commented on Mar 22, 2023

    @josephlr
    Member

    I think we should just need contents: read for our CI jobs, as they otherwise just download public data.

    Unlike rust-osdev/x86_64#412, we don't currently publish via Github Actions, so we don't need contents: write

  3. added a commit that references this issue on Mar 24, 2023
    0b9c0b8
  4. added a commit that references this issue on Feb 8, 2024
    03defac
  5. added a commit that references this issue on Jan 27, 2026
    f28950b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions