Skip to content

Restrict GITHUB_TOKEN permissions in workflows - #703

Merged
ecomodeller merged 1 commit into
mainfrom
workflow-permissions
Aug 26, 2026
Merged

Restrict GITHUB_TOKEN permissions in workflows#703
ecomodeller merged 1 commit into
mainfrom
workflow-permissions

Conversation

@ecomodeller

Copy link
Copy Markdown
Member

Workflows without an explicit permissions block use the repository or organization default token permissions. For repositories created before February 2023 that default is read-write, so every job runs with a token that can push to the repo even though all it does is check out and run tests.

CodeQL flags this as actions/missing-workflow-permissions (7 open alerts). Setting the permissions explicitly documents what each workflow actually needs and keeps it restricted if the default changes or the workflow is copied elsewhere.

contents: read at the workflow root is enough for all of them; the PyPI deploy job keeps id-token: write for trusted publishing and now states contents: read too, since a job-level block replaces rather than extends the root one.

See Assigning permissions to jobs.

CodeQL (actions/missing-workflow-permissions) flags workflows without an
explicit permissions block: they fall back to the repository/organization
default, which for repos created before February 2023 is read-write.

Add 'permissions: contents: read' at the top of each workflow that only
needs to read the repository, and make the PyPI deploy job's existing
job-level block explicit about contents: read alongside id-token: write.
@ecomodeller
ecomodeller merged commit c0f16f4 into main Aug 26, 2026
10 checks passed
@ecomodeller
ecomodeller deleted the workflow-permissions branch August 26, 2026 11:58
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.

1 participant