Skip to content

ci: restrict default token permissions to read-only - #8440

Open
alexisLefebvre wants to merge 2 commits into
api-platform:4.3from
alexisLefebvre:restrict-workflow-token-permissions
Open

ci: restrict default token permissions to read-only#8440
alexisLefebvre wants to merge 2 commits into
api-platform:4.3from
alexisLefebvre:restrict-workflow-token-permissions

Conversation

@alexisLefebvre

@alexisLefebvre alexisLefebvre commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
Q A
Branch? 4.3
Bug fix? no
New feature? no
Deprecations? no
Issues
License MIT
Doc PR

What

Declares a top-level permissions: contents: read in the CI, Guides and Release Pipeline workflows. Commit Lint already had one and is untouched.

Nothing in the CI or Guides workflows writes back to GitHub — no git push, no gh call, no PR-creating action. Artifact upload and dependency caching authenticate with ACTIONS_RUNTIME_TOKEN, not GITHUB_TOKEN, so they are unaffected by the restriction.

Release Pipeline does push: its subtree-split job runs subtree.sh, which splits each src/* component and pushes the result to the matching per-component repository. It nonetheless loses the contents: write that job declared, because that grant was never what authorised those pushes — every target is a separate repository (api-platform/serializer, api-platform/state, …), and GITHUB_TOKEN is scoped to this repository alone, so no permission level on it could reach them. The credential that does authorise them is the GitHub App token, which actions/checkout receives explicitly and stores as a host-scoped http.https://github.com/.extraheader, applying to the remotes the script adds afterwards. No step in the workflow references GITHUB_TOKEN at all, so all three jobs run read-only and the release process is unchanged.

Why

With no explicit block, GITHUB_TOKEN inherits the repository or organisation default, which on older settings is read and write across every scope. That is ambient authority these jobs never exercise: any compromised step, dependency or action in a run triggered from a branch push could use it to push commits, edit issues, or alter releases.

Declaring the scopes makes the grant match the work, and also pins it against a future change to the org-wide default.

🤖 Generated with Claude Code

alexisLefebvre and others added 2 commits August 4, 2026 14:55
Without an explicit block, the automatic token inherits whatever the
repository or organisation default grants, which can include write
scopes. Neither workflow writes anything back to GitHub, so a
compromised step or action had more reach than the work required.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Every job here authenticates through a GitHub App token, so the
automatic token is never used: the write grant it carried could not
authorise the pushes to the component repositories anyway, since its
scope is limited to this repository.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@alexisLefebvre
alexisLefebvre force-pushed the restrict-workflow-token-permissions branch from f66256f to fd973c4 Compare August 4, 2026 13:10
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