Skip to content

fix(workflows): drop vestigial job-level GITHUB_TOKEN write grants - #1137

Merged
c-vigo merged 2 commits into
devfrom
bugfix/1136-vestigial-token-permissions
Jul 15, 2026
Merged

c-vigo merged 2 commits into
devfrom
bugfix/1136-vestigial-token-permissions

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1136

What

An OpenSSF Scorecard TokenPermissions audit (on vig-os/commit-action) traced every job-level contents: write / actions: write grant in the rendered release/sync workflow templates to the token that actually performs the write. Every git push, tag push, gh release, gh pr, gh api mutation and gh workflow run rides a COMMIT_APP / RELEASE_APP installation token, not the job's GITHUB_TOKEN — so those grants are vestigial. This reduces them to read at the source (assets/workspace/.github/workflows/), propagating to all consumers on upgrade.

Reductions (write → read on GITHUB_TOKEN)

Template Job Grant
prepare-release.yml prepare, rollback contents
promote-release.yml validate, promote, merge, cleanup, floating-tags contents
release.yml core caller actions + contents
release.yml publish caller, rollback contents
release-core.yml finalize actions + contents
release-publish.yml publish contents
sync-issues.yml sync contents
sync-main-to-dev.yml sync contents

Caller/callee pairs (release.yml core/publish ↔ release-core.yml/release-publish.yml) are lowered on both sides in the same change.

Two grants handled with care

  1. promote-release.yml validate — its Verify draft GitHub Release exists step listed releases with GH_TOKEN: github.token and matched a draft; GitHub only returns drafts to a push-capable token, so a bare read-only token would hide the draft and fail every promotion. The step now uses the RELEASE_APP token the job already mints, so the job can safely drop to contents: read.
  2. sync-issues.yml sync actions: write — kept. Its Delete old cache step calls gh api .../actions/caches/{id} -X DELETE on github.token.

Optional same-justification extras (pull-requests/issues write on App-token-driven jobs, not Scorecard-flagged) are deliberately left in place — out of scope here.

Verification

  • TDD: flipped tests/bats/just.bats to pin the release caller/callee GITHUB_TOKEN blocks read-only (RED → GREEN).
  • bats tests/bats/just.bats — 46/46 pass.
  • pytest on test_promote_mergeability, test_floating_tags, test_release_tag_prefix, test_workflow_prepare_extension — 30/30 pass.
  • Full just precommit (incl. actionlint, yamllint, sync-manifest) green.
  • Downstream precedent: vig-os/commit-action#94/#95 moved the repo-local smoke workflows to permissions: {} + job-level write with E2E and published-tag smokes passing.

Pre-merge validation

The devcontainer-smoke-test repository_dispatch flow already renders these templates into a real target and drives the full pipeline against them with real RELEASE_APP/COMMIT_APP tokens, so the App-token writes are genuinely exercised (a broken reduction fails the write and errors the wait step):

  • prepare-release → release → release-core finalize → sync-issues (finalize triggers it and waits, so a broken sync-issues permission fails the release the dispatch is waiting on)
  • promote-release → merge → push to main → sync-main-to-dev

Caveat: promote-release is gated if release_kind == 'final'. An RC-only dispatch covers prepare + release + release-core + release-publish + sync-issues, but not promote-release or (transitively) sync-main-to-dev. To give the promote-release changes — including the load-bearing validate Verify draft GitHub Release exists GH_TOKEN fix — live coverage, validate with a final dispatch, not just a candidate.

Refs: #1136

c-vigo added 2 commits July 15, 2026 19:14
Every job-level contents:write / actions:write grant in the rendered
release and sync workflow templates is written to by a COMMIT_APP or
RELEASE_APP installation token, never the job's GITHUB_TOKEN. Reduce those
grants to read across prepare-release, promote-release, release,
release-core, release-publish, sync-issues and sync-main-to-dev, shrinking
the blast radius of a compromised step to a read-only GITHUB_TOKEN.

Point promote-release validate's draft-release check at the RELEASE_APP
token (GitHub only returns drafts to a push-capable token) so the job can
drop to contents:read. Keep sync-issues sync's actions:write — its cache
deletion calls gh api -X DELETE on github.token.

Refs: #1136
@c-vigo
c-vigo merged commit 5113842 into dev Jul 15, 2026
13 checks passed
@c-vigo
c-vigo deleted the bugfix/1136-vestigial-token-permissions branch July 15, 2026 17:28
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