ci(documentation): cap GITHUB_TOKEN to contents: read#3291
ci(documentation): cap GITHUB_TOKEN to contents: read#3291arpitjain099 wants to merge 2 commits into
Conversation
Workflow runs checks only; no GitHub API writes. Post-CVE-2025-30066 hardening pattern. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 18d250d. Configure here.
|
@arpitjain099 thanks, i will have a look |
nkaradzhov
left a comment
There was a problem hiding this comment.
Upload step pushes to gh-pages branch via npm run gh-pages (line 26-27), authenticating with GITHUB_TOKEN. With contents: read only, the push fails (403 Forbidden / remote: Permission denied).
"YAML validated locally" only checks syntax, not runtime token scope. No CI run on master/v4.0 push has exercised this yet.
Fix — least-privilege per job:
permissions:
contents: read
jobs:
documentation:
permissions:
contents: write # required for gh-pages push
runs-on: ubuntu-latest
Keeps workflow-level read-only default, grants write only to the job that needs it. Still a hardening win vs. the implicit default GITHUB_TOKEN scope.
@nkaradzhov ok I'll check this out later tonight. |
Per review feedback (@nkaradzhov): the Upload step pushes generated docs to gh-pages via 'npm run gh-pages', which needs contents: write. Keeping workflow-level contents: read as the least-privilege default and only elevating the documentation job, per least-privilege-per-job pattern. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
|
Thanks @nkaradzhov, you are absolutely right - the |
1 similar comment
|
Thanks @nkaradzhov, you are absolutely right - the |

Pins the default
GITHUB_TOKENtocontents: readat workflow level. No GitHub API writes from the workflow.Post-CVE-2025-30066 (
tj-actions/changed-files) hardening pattern. YAML validated locally.Note
Low Risk
CI-only permission tightening with an explicit write grant on the job that publishes docs; no runtime or application code changes.
Overview
Hardens the Documentation workflow by setting workflow-level
permissionstocontents: read, so the defaultGITHUB_TOKENcannot write to the repo unless a job opts in.The
documentationjob overrides withcontents: writeso the existing gh-pages push step can still publish generated docs.Reviewed by Cursor Bugbot for commit ad10fc9. Bugbot is set up for automated code reviews on this repo. Configure here.