Skip to content

chore(ci): pin GITHUB_TOKEN to contents:read in the CI workflow - #104

Open
Bircck wants to merge 1 commit into
mainfrom
chore/workflow-token-permissions
Open

Bircck wants to merge 1 commit into
mainfrom
chore/workflow-token-permissions

Conversation

@Bircck

@Bircck Bircck commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Closes the two open CodeQL alerts of rule actions/missing-workflow-permissions on main (#1, #2), and stops the github-advanced-security bot from leaving a review comment on every PR that touches the CI workflow.

What the alert actually says

When a workflow declares no permissions: block, GITHUB_TOKEN is minted with the repository's default scopes. On older repos that default is read and write across contents, issues, pull requests, packages and more. Every step in the job — including third-party actions — can use that token. The rule's point is that a build-and-test job should not be handed a token that can push commits or publish packages.

It is a hardening finding, not an exploited vulnerability. Nothing in this workflow misuses the token; the fix is to stop handing it out.

The change

A workflow-level block covering both jobs:

permissions:
  contents: read

contents: read is all that is needed here — actions/checkout reads the ref, setup-dotnet / setup-node read nothing from the repo, and the remaining steps are dotnet build, dotnet test, npm ci, npm run lint and npm run build. No step pushes, tags, comments or calls the API.

release-prepare.yml and release-publish.yml already declare their own (wider, and correctly so) permissions blocks and are untouched.

Note for #103

#103 renames this file to ci.yml, so it carries its own copy of the alert. Once that branch takes in main, the rename carries this block across and the alert clears there too.

CodeQL's actions/missing-workflow-permissions rule flags every job that
leaves GITHUB_TOKEN at the repository default, so the CI workflow's two
jobs produce an alert on main and a github-advanced-security review
comment on any PR that touches the file.

Both jobs only check out, build and test; neither pushes, comments or
calls the API. A workflow-level contents:read covers them and closes the
alert at its source.
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