google / sentencepiece

Unsupervised text tokenizer for Neural Network-based text generation.
Apache License 2.0
10.25k stars 1.17k forks source link

Ensure workflows run with minimal permissions #937

Closed pnacht closed 10 months ago

pnacht commented 11 months ago

Hi, it's Pedro and I'm back (see https://github.com/google/sentencepiece/pull/934) with another security suggestion!

Describe the bug SentencePiece's automated workflows currently run with write-all tokens. This puts the project at risk of supply-chain attacks. GitHub recommends ensuring all workflows run with minimal permissions.

I've taken a look at the workflows and they don't need broad permissions.

This issue can be solved in two ways:

I'll be sending a PR along with this issue that sets the top-level permissions (and grants additional permissions for the jobs that need them). If you instead (or also) wish to modify the default token permissions:

  1. Open the repo settings
  2. Go to Actions > General
  3. Under "Workflow permissions", set them to "Read repository contents and packages permissions"