Skip to content

ci: add explicit GITHUB_TOKEN permission scopes to workflows - #1364

Open
Makeph wants to merge 1 commit into
GitGuardian:mainfrom
Makeph:ci/explicit-github-token-permissions
Open

ci: add explicit GITHUB_TOKEN permission scopes to workflows#1364
Makeph wants to merge 1 commit into
GitGuardian:mainfrom
Makeph:ci/explicit-github-token-permissions

Conversation

@Makeph

@Makeph Makeph commented Jul 28, 2026

Copy link
Copy Markdown

Closes #1350.

No workflow declared a permissions: block, so every job ran with the repository's default GITHUB_TOKEN scopes. Depending on repository and organisation settings, those defaults can include write access to contents, packages and pull requests — considerably more than any of these jobs needs.

I went through every workflow under .github/workflows/, not just the two named in the issue. Each one now denies everything at the top level (permissions: {}) and grants the minimum back per job.

What each job got, and why

Workflow Job Scopes Reason
build_release_assets.yml build_wheel_sdist, build_os_packages contents: read checkout
linux_package_smoke_tests none only consumes artifacts from its own run
changelog-check.yml check-changelog none the action takes no token input and works anonymously on public repos
ci.yml lint, build, functest_api, test_github_secret_scan_action contents: read checkout; Codecov and GitGuardian use their own credentials
build_os_packages contents: read passed through to the reusable workflow
push_docker_images-unstable contents: read, packages: write GHCR publishing; Docker Hub uses separate credentials
install-scripts.yml bats contents: read checkout, plus authenticated public release API reads
perfbench.yml benchmark contents: read checkout with full history
tag.yml release contents: write, id-token: write, attestations: write unchanged — creates the release, uploads assets, writes provenance
push_to_pypi, push_to_cloudsmith, push_to_chocolatey contents: read checkout; each publishes with its own API key
push_docker_images contents: read, packages: write GHCR publishing
update-downstream.yml update-ggshield-version none checkout, push and PR creation all use PAT_GITHUB

Two things worth flagging

  • tag.yml references ./.github/workflows/update_vscode_extension.yml, but that file isn't present in the repository. I left that job's permissions untouched (it inherits the empty default) since I can't see what it needs — happy to adjust if you can tell me.
  • Workflow changes in a fork PR aren't executed by CI (pull_request runs use the base branch's workflow files), so this can't be validated by the checks on this PR. I verified statically that all seven files parse and that the resulting permission tree is what's described above. You may want to confirm on a branch in the main repo before merging.

If you'd rather have a single workflow-level contents: read instead of permissions: {} plus per-job grants, say the word and I'll rework it.


Prepared with AI assistance; I reviewed every line and verified the YAML parses and resolves to the permission tree documented above.

No workflow declared a `permissions:` block, so every job ran with the
repository's default GITHUB_TOKEN scopes. Depending on repository and
organisation settings those defaults can include write access to
contents, packages and pull requests, which is far more than any of
these jobs need.

Each workflow now denies everything at the top level and grants the
minimum back per job:

- contents: read wherever a job checks out the repository
- packages: write only for the jobs publishing to GHCR
- contents/id-token/attestations: write kept as-is for the release job

Jobs that never touch GITHUB_TOKEN keep the empty default: the artifact
smoke tests only consume artifacts from their own run, the changelog
check works anonymously on public repositories, and update-downstream
authenticates with PAT_GITHUB throughout.

Closes GitGuardian#1350
@Makeph
Makeph requested a review from a team as a code owner July 28, 2026 10:23
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.

Bug: Add explicit GITHUB_TOKEN permission scopes to workflows

1 participant