Repository navigation
Give each workflow's token only the permissions it needs #1333
Copy link
Copy link
Open
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Problem
When a workflow doesn't declare permissions:, its GITHUB_TOKEN gets the repository's default permissions, which can include write access to contents, pull requests, issues and more. If a step or third-party action is ever compromised, it can use that token. The OpenSSF Scorecard Token-Permissions check asks for a read-only token at the top level of every workflow, with any write permission granted only on the job that needs it.
In python-sdk, only automerge-queue.yaml sets a top-level permissions: today ({}). These workflows have none:
build.yamlandbuild-tag.yaml(their codecov jobs setcontents: readandid-token: writeat job level, but the other jobs inherit the default)release-tag.yaml(job-levelcontents: readonly)run-tests.yamlfossa.yamldapr-bot.ymlbackport.yamlanddapr-bot-schedule.yml(these call reusable workflows in dapr/.github)
Proposed change
For each workflow:
- Add a top-level
permissions: contents: read(orpermissions: {}where no job reads the repo). - Grant write scopes only on the job that needs them, keeping the existing job-level blocks (for example codecov's
id-token: write). - Several workflows do their writes with
DAPR_BOT_TOKENor a PyPI secret, notGITHUB_TOKEN(dapr-bot.yml,release-tag.yaml,build-tag.yaml's upload,backport.yaml,dapr-bot-schedule.yml). Those jobs shouldn't need write scopes onGITHUB_TOKEN. - For jobs that call reusable workflows (
uses: dapr/.github/.github/workflows/...), the caller's permissions cap what the called workflow gets, so check what each reusable workflow needs before restricting it.build-tag.yamlalready does this foropen-issue-on-failure.yml.
Acceptance criteria
- Every workflow in
.github/workflows/has a top-levelpermissions:block that is read-only (contents: read,read-allor{}). - Write scopes appear only at job level, on the jobs that need them.
- CI on the PR is green, and the release, bot and scheduled workflows are checked by reading through what they call (or by a test run on a fork).
How to test
actionlintpasses on the changed workflows.- The PR's CI runs (
build.yaml,run-tests.yaml) pass. - To exercise scheduled and comment-triggered workflows, run them on your fork via
workflow_dispatchor the triggering event. - Optionally, run the scorecard CLI with
--checks=Token-Permissionsagainst your fork and confirm no findings.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Activity
AlphaNen commentedon Oct 21, 2026
/assign
ci: restrict GITHUB_TOKEN permissions in workflows