Repository navigation
Restrict workflow token permissions by default - #389
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 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: readand seven publish callersactions: read,contents: read, andpackages: 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
force-pushed
the
dh/workflow-token-permissions
branch
from
November 3, 2026 10:46
4ecfd52 to
099d7c4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
permissions: {}at workflow level in all 18 workflows.contents: readand the seven publish callersactions: read,contents: read, andpackages: write, exactly matching their callees' existing grants.contents: writeconfined 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.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.