Skip to content

Restrict GITHUB_TOKEN scope in workflows (least privilege)#5

Merged
donbagger merged 1 commit intomainfrom
security/workflow-permissions
May 7, 2026
Merged

Restrict GITHUB_TOKEN scope in workflows (least privilege)#5
donbagger merged 1 commit intomainfrom
security/workflow-permissions

Conversation

@r--w
Copy link
Copy Markdown
Member

@r--w r--w commented Apr 27, 2026

Summary

Why

Without an explicit permissions: block, the default GITHUB_TOKEN inherits whatever the repo/org-wide default is - historically read-write on older orgs. Both jobs only need to read the repo:

  • tests.yml: checks out code and runs pytest
  • publish.yml: checks out code and uploads to PyPI via TWINE_USERNAME / TWINE_PASSWORD secrets (independent of GITHUB_TOKEN)

Test plan

  • Confirm the Tests workflow still runs on this PR (it should - read-only is sufficient for checkout + pytest).
  • After merge, cut a release and verify publish.yml still publishes to PyPI (TWINE secrets are unaffected by GITHUB_TOKEN scope).
  • Verify the two CodeQL alerts auto-close.

Add explicit `permissions: contents: read` to publish.yml and tests.yml
so the default GITHUB_TOKEN no longer inherits broader repo/org defaults.

Resolves CodeQL alerts actions/missing-workflow-permissions (#1, #2).
@donbagger donbagger merged commit dc2d6ef into main May 7, 2026
7 checks passed
@donbagger donbagger deleted the security/workflow-permissions branch May 7, 2026 17:15
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.

2 participants