Skip to content

ci: restrict GITHUB_TOKEN permissions in workflows - #1334

Open
AlphaNen wants to merge 2 commits into
dapr:mainfrom
AlphaNen:fix/workflow-token-permissions
Open

AlphaNen wants to merge 2 commits into
dapr:mainfrom
AlphaNen:fix/workflow-token-permissions

Conversation

@AlphaNen

Copy link
Copy Markdown

Description

Add a read-only top-level permissions: block to every workflow that was missing one, so GITHUB_TOKEN no longer inherits the repository's default write scopes. Workflows that check out the repo use contents: read; workflows that only write via DAPR_BOT_TOKEN (or call reusable workflows that do) use permissions: {}.

Existing job-level write grants are unchanged:

  • build.yaml / build-tag.yaml codecov jobs: id-token: write
  • build-tag.yaml notify-on-failure: issues: write and actions: read

Reusable workflow callers (backport.yaml, dapr-bot-schedule.yml) stay at permissions: {} because the called workflows in dapr/.github already declare permissions: {} and use DAPR_BOT_TOKEN.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #1333

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@AlphaNen
AlphaNen requested review from a team as code owners October 21, 2026 22:54
@CasperGN CasperGN self-assigned this Oct 21, 2026
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.27%. Comparing base (fddc30f) to head (d0edf75).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1334   +/-   ##
=======================================
  Coverage   87.27%   87.27%           
=======================================
  Files         163      163           
  Lines       13069    13069           
=======================================
  Hits        11406    11406           
  Misses       1663     1663           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sreyasts

Copy link
Copy Markdown

I maintain Workflow Lens, an AI-assisted local workflow reviewer. I used it to compare all eight changed workflows at fddc30f → d0edf75 for this PR.

Two useful review checks:

  • build.yaml and build-tag.yaml: the build jobs keep their explicit contents: read + id-token: write. build-tag.yaml also keeps notify-on-failure at issues: write + actions: read.
  • release-tag.yaml: the tag job already explicitly requested contents: read, so the new workflow default does not change that job's requested scopes.

Where an old workflow omitted permissions, the comparison keeps the baseline as unknown; it cannot establish the old repository-default budget. It also does not resolve access through DAPR_BOT_TOKEN or prove runtime behavior.

Would you try one actual comparison and tell me whether it adds anything beyond GitHub's diff?

For build-tag.yaml: open the old file, paste it into Workflow Lens, choose Use current as baseline, then paste the proposed file. It runs locally without sign-in or workflow uploads.

One confusing/wrong result—or “the normal diff is easier”—would help. No endorsement or star needed.

Comment thread .github/workflows/release-tag.yaml Outdated
Comment on lines 38 to 39

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can go now that we have it in the top level, right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch — removed the job-level permissions on tag so contents: read only lives at the workflow top level. Pushed in c99e480.

AlphaNen added a commit to AlphaNen/python-sdk that referenced this pull request Oct 23, 2026
Declare a read-only top-level permissions block on every workflow so a
compromised step cannot inherit the repository's default write scopes.
Keep existing job-level write grants (codecov OIDC, release failure issues).

Fixes dapr#1333

Signed-off-by: DevAsadYasin <dev.asad.yasin@gmail.com>
AlphaNen added a commit to AlphaNen/python-sdk that referenced this pull request Oct 23, 2026
@AlphaNen
AlphaNen force-pushed the fix/workflow-token-permissions branch from c99e480 to af7b08f Compare October 23, 2026 18:48
Signed-off-by: Asad Yasin <dev.asad.yasin@gmail.com>
@AlphaNen
AlphaNen force-pushed the fix/workflow-token-permissions branch from af7b08f to 5d97de9 Compare October 25, 2026 11: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.

Give each workflow's token only the permissions it needs

4 participants