Skip to content

Restrict workflow token permissions by default - #389

Merged
damianh merged 1 commit into
mainfrom
dh/workflow-token-permissions
Nov 3, 2026
Merged

damianh merged 1 commit into
mainfrom
dh/workflow-token-permissions

Conversation

@damianh

@damianh damianh commented Nov 2, 2026

Copy link
Copy Markdown
Member

What issue does this PR address?

The workflows inherit repository-wide write permissions unless each job overrides them. This addresses the 18 Scorecard TokenPermissionsID alerts for missing restrictive workflow defaults (#49 and #154-170) without removing permissions required by existing jobs.

  • Set permissions: {} at workflow level in all 18 workflows.
  • Give the seven CI reusable-workflow callers contents: read and the seven publish callers actions: read, contents: read, and packages: write, exactly matching their callees' existing grants.
  • Preserve all executable-job permissions, including CodeQL uploads and package publication. Keep contents: write confined to the release tag job. Alert Some minor cleanups for DPoP AdditionalDPoPPayloadClaims #153 remains intentionally unresolved because creating/deleting release tags requires this grant.

Validation:

  • go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 -color -shellcheck= -pyflakes=: passed (optional shellcheck and pyflakes checks disabled).
  • git diff --check: passed before committing.
  • Inline Python/PyYAML checks: passed for all 18 workflow documents, all 23 job definitions, exact permission compatibility across all 14 reusable calls, preserved release/CodeQL grants, and structural comparison confirming no non-permission changes.

No publishing, tagging, or release workflows were dispatched. GitHub execution is still needed to confirm runtime token enforcement and a fresh Scorecard scan is needed to confirm alert resolution. Repository settings and alert dismissals are unchanged.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 17:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the changes that narrow GitHub Actions token permissions.

No open issues 🎉

What changed in this PR

This PR hardens GitHub Actions token permissions across all 18 workflows, replacing inherited repository-wide permissions with explicit job-level grants.

Changes:

  • Add permissions: {} as the default in every workflow.
  • Grant seven CI callers contents: read and seven publish callers actions: read, contents: read, and packages: write.
  • Leave existing executable-job permissions unchanged, preserving CodeQL uploads, package publication, and release tagging.

Runtime token enforcement and Scorecard alert resolution still require GitHub execution.

File Description
.github/​workflows/​release.yml Restrict defaults; retain release-job grants.
.github/​workflows/​razor-slices-publish.yml Restrict defaults; explicitly grant publish permissions.
.github/​workflows/​razor-slices-ci.yml Restrict defaults; explicitly grant CI read access.
.github/​workflows/​publish-template.yml Restrict reusable publishing workflow defaults.
.github/​workflows/​memory-cache-publish.yml Restrict defaults; explicitly grant publish permissions.
.github/​workflows/​memory-cache-ci.yml Restrict defaults; explicitly grant CI read access.
.github/​workflows/​introspection-publish.yml Restrict defaults; explicitly grant publish permissions.
.github/​workflows/​introspection-ci.yml Restrict defaults; explicitly grant CI read access.
.github/​workflows/​ignore-this-publish.yml Restrict defaults; explicitly grant publish permissions.
.github/​workflows/​ignore-this-ci.yml Restrict defaults; explicitly grant CI read access.
.github/​workflows/​identity-model-publish.yml Restrict defaults; explicitly grant publish permissions.
.github/​workflows/​identity-model-oidc-client-publish.yml Restrict defaults; explicitly grant publish permissions.
.github/​workflows/​identity-model-oidc-client-ci.yml Restrict defaults; explicitly grant CI read access.
.github/​workflows/​identity-model-ci.yml Restrict defaults; explicitly grant CI read access.
.github/​workflows/​codeql.yml Restrict defaults; retain analysis-job grants.
.github/​workflows/​ci-template.yml Restrict reusable CI workflow defaults.
.github/​workflows/​access-token-management-publish.yml Restrict defaults; explicitly grant publish permissions.
.github/​workflows/​access-token-management-ci.yml Restrict defaults; explicitly grant CI read access.

Review effort: Balanced

Deny permissions by default instead of inheriting repository write access.
Grant reusable callers exactly the scopes their jobs need, preserving
package publication, CodeQL uploads, and release tag writes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@damianh
damianh force-pushed the dh/workflow-token-permissions branch from 4ecfd52 to 099d7c4 Compare November 3, 2026 10:46
Copilot AI balanced review requested due to automatic review settings November 3, 2026 10:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the workflow token-permission hardening.

No open issues 🎉

Review effort: Balanced

@damianh
damianh merged commit bbb95e1 into main Nov 3, 2026
26 checks passed
@damianh
damianh deleted the dh/workflow-token-permissions branch November 3, 2026 10:49
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