Skip to content

ci(github): scope workflow GITHUB_TOKEN to contents:read (#330)#331

Merged
CryptoJones merged 1 commit into
masterfrom
ci/workflow-least-privilege-permissions
May 19, 2026
Merged

ci(github): scope workflow GITHUB_TOKEN to contents:read (#330)#331
CryptoJones merged 1 commit into
masterfrom
ci/workflow-least-privilege-permissions

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #330.

Summary

Adds an explicit permissions: contents: read block to .github/workflows/test.yml so the auto-provisioned GITHUB_TOKEN can't be coerced into pushing to master / opening issues / manipulating PRs if a dependency or action in the workflow is compromised.

The test workflow only needs to clone the repo and report status — no write surface required.

Test plan

  • npm run lint && npm test — 783 passing (CI config change, no app-side impact).

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

The `tests` workflow had no explicit `permissions:` block, which
means the auto-provisioned GITHUB_TOKEN inherits the repository
default — typically read+write on contents, issues, pull-requests,
and a handful of other surfaces. A compromised dependency, a
malicious upstream action, or a workflow-injection foothold via
PR-author-controlled input could then push to master, open
issues, or close/comment PRs using the workflow token.

The test workflow only needs to clone the repo and report status
via the default check API — no write surface required. Pin the
job-level scope to `contents: read` so any future compromise can
do strictly less damage. Matches the GitHub Actions hardening
guide's "least-privilege GITHUB_TOKEN" recommendation.

Codeberg's Woodpecker runner has a different token model (no
auto-provisioned write-capable token; it uses a per-pipeline
secret instead), so the .woodpecker.yml side needs no parallel
change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit 0afda84 into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the ci/workflow-least-privilege-permissions branch May 19, 2026 18:24
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.

GH Actions workflow lacks explicit permissions: block (token has default repo write access)

1 participant