Skip to content

Commit 809b9fd

Browse files
cliffhallclaude
andauthored
ci: set a least-privilege default GITHUB_TOKEN scope (#1831)
CodeQL alert #64 (`actions/missing-workflow-permissions`, medium) on `.github/workflows/main.yml`: no `permissions` block, so every job inherits the repository's default GITHUB_TOKEN scope, which is broader than anything here needs. It matters more than the severity suggests because this is the workflow that publishes to npm under OIDC — an over-permissioned token in a job that mints publish credentials is worth tightening before 2.0.0 ships (#1818). Adds a workflow-level `permissions: contents: read`. The `publish` and `publish-github-container-registry` jobs already declare their own blocks (`id-token: write` and friends) and are unaffected: job-level permissions override the workflow-level default outright rather than merging with it. The comment records that, since it means each publish job must keep listing every scope it needs — including `contents: read` — and a future edit that trims one "because it's inherited" would break the publish. Surfaced by the v2 tree swap (#1817): `main` had never scanned this workflow before. Pre-existing on `v2/main`, not introduced by that merge. Claude-Session: https://claude.ai/code/session_01Txmv2qqv3yeKgRzoqXytzD Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 25106dc commit 809b9fd

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ on:
88
release:
99
types: [published]
1010

11+
# Default least-privilege scope for GITHUB_TOKEN. Without this, jobs inherit the
12+
# repository's default token permissions, which are broader than any job here
13+
# needs (CodeQL `actions/missing-workflow-permissions`). The `publish` and
14+
# `publish-github-container-registry` jobs declare their own blocks below, which
15+
# override this one entirely rather than adding to it — so each publish job must
16+
# continue to list every scope it needs, including `contents: read`.
17+
permissions:
18+
contents: read
19+
1120
jobs:
1221
build:
1322
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)