Skip to content

ci: set least-privilege GITHUB_TOKEN permissions#12

Merged
Technologicat merged 1 commit into
mainfrom
harden/token-permissions
Jun 11, 2026
Merged

ci: set least-privilege GITHUB_TOKEN permissions#12
Technologicat merged 1 commit into
mainfrom
harden/token-permissions

Conversation

@Technologicat

Copy link
Copy Markdown
Owner

Least-privilege GITHUB_TOKEN: adds top-level permissions: contents: read to every workflow.

Jobs otherwise inherit the repo-default token scope (often read-write). A poisoned transitive dependency running during install/build/test on a push to the default branch would then hold a write-capable token (push commits, cut releases). Read-only by default denies that. Publish jobs keep their own job-level id-token: write (job-level overrides the top-level default), so PyPI trusted publishing is unaffected.

Defense-in-depth complement to the SHA-pinning: pinning stops untrusted code from running; this caps what it can do. Fork-PR tokens are already read-only by GitHub design — this closes the push-triggered path.

🤖 Generated with Claude Code

Add top-level `permissions: contents: read` to every workflow. Without
it, jobs inherit the repo-default token scope (often read-write), so a
malicious dependency executing during install/build/test on a push to
the default branch would hold a write-capable token. Read-only by
default denies that; the publish job keeps its own job-level
`id-token: write` block (job-level permissions override the top-level
default), so trusted-publishing is unaffected.

Complements the SHA-pinning: pinning stops untrusted code from running;
this limits what it can do if it runs anyway. Fork-PR tokens are already
forced read-only by GitHub; this closes the push-triggered path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Technologicat Technologicat merged commit e9a5404 into main Jun 11, 2026
5 checks passed
@Technologicat Technologicat deleted the harden/token-permissions branch June 11, 2026 21:23
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