Skip to content

fix(ci): scope GITHUB_TOKEN permissions per job (#15) - #16

Open
hf-security-analysis[bot] wants to merge 2 commits into
dependabot/github_actions/actions-c20c00cd42from
security/workflow-hardening/pr-15-permissions
Open

hf-security-analysis[bot] wants to merge 2 commits into
dependabot/github_actions/actions-c20c00cd42from
security/workflow-hardening/pr-15-permissions

Conversation

@hf-security-analysis

@hf-security-analysis hf-security-analysis Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Automated hardening of the workflow files flagged on #15: job permissions only.

Each kind of fix has its own pull request, from a security/workflow-hardening/pr-15-* branch, and any of them can be merged first: the others are rebuilt on top when this one lands.

Warning

This changes when the workflow runs and what it can reach. Both triggers and permissions were rewritten in .github/workflows/build-pr-dispatch.yaml, .github/workflows/build-windows.yaml, .github/workflows/build.yaml, .github/workflows/nix_fmt.yaml. Read the diff before merging — either one can change what the workflow is able to do.

Targets dependabot/github_actions/actions-c20c00cd42. Files changed, and what changed them:

  • .github/workflows/build-pr-dispatch.yaml — job permissions
  • .github/workflows/build-windows.yaml — job permissions
  • .github/workflows/build.yaml — job permissions
  • .github/workflows/nix_fmt.yaml — job permissions

Fixed by this PR:

  • HIGH excessive-permissions (zizmor) — .github/workflows/build-pr-dispatch.yaml:11
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/nix_fmt.yaml:1
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/nix_fmt.yaml:11
  • LOW excessive-permissions (zizmor) — .github/workflows/build-pr-dispatch.yaml:12
  • LOW excessive-permissions (zizmor) — .github/workflows/build-windows.yaml:63
  • LOW excessive-permissions (zizmor) — .github/workflows/build.yaml:63

This does not fix everything. 4 further finding(s) (3 high, 1 medium) need a decision this bot should not make for you. They are in the security channel with their locations — deliberately not repeated here, since this repository may be public and they are not fixed yet.

Permissions

.github/workflows/build-pr-dispatch.yaml

job granted why
dispatch actions: write, contents: read, statuses: write actions/checkout needs contents: read, and the 'Dispatch build workflows' step runs .github/scripts/dispatch.py with GITHUB_TOKEN to trigger per-platform workflows (actions: write). statuses: write is kept from the existing grant, presumably for posting PR commit statuses. The script itself is not in this file, so the reviewer should confirm it only dispatches workflows and sets statuses.

.github/workflows/build-windows.yaml

job granted why
set-running-status statuses: write The 'Set running status' step calls gh api repos/$REPO/statuses/$HEAD_SHA to create a pending commit status, which requires statuses: write.
build-kernel contents: read actions/checkout of this repo (and the public huggingface/kernels repo) needs contents: read; uploads go to the Hugging Face Hub via HF_TOKEN, and the install-oneapi.ps1/builder.ps1 scripts receive no GitHub token, so no other scope is needed.
report-status statuses: write The 'Set commit status' step calls gh api repos/$REPO/statuses/$HEAD_SHA to post the final commit status, which requires statuses: write.

.github/workflows/build.yaml

job granted why
setup contents: read, statuses: write The 'Set running status' step POSTs to repos/$REPO/statuses/$HEAD_SHA via gh api (statuses: write), and actions/checkout needs contents: read.
build-kernel contents: read, id-token: write The 'Sign kernel metadata' step runs cosign sign-blob keylessly, which needs id-token: write; checkout needs contents: read; no step posts statuses, and upload-artifact plus the Hub uploads (HF_TOKEN) need no GitHub scope.
build-ci-test contents: read Only actions/checkout needs contents: read; the nix builds, cachix and same-run upload-artifact need no token scopes.
test-kernel-gpu {} — nothing No checkout and no API use; download-artifact from the same run needs no permission.
report-status contents: read, issues: write, statuses: write The 'Update bot comment with Hub URLs' step PATCHes repos/.../issues/comments/$BOT_COMMENT_ID (issues: write), and 'Set commit status' posts to the statuses API (statuses: write); checkout needs contents: read, while same-run download-artifact needs no actions: read.

.github/workflows/nix_fmt.yaml

job granted why
build contents: read actions/checkout needs contents: read; the Nix installer and nix fmt -- --ci run locally and use no repository token scopes.

.github/workflows/pr-comment-build.yaml

handle-comment was left as it is — The final step runs .github/scripts/pr_comment_kernel_bot.py with GITHUB_TOKEN, and that script's contents are not in this file, so its API usage (likely comments/reactions and possibly workflow dispatch, given the workflow-level actions/issues/pull-requests write grants) cannot be verified; checkout and git fetch alone need only contents: read.

.github/workflows/security-audit.yml

job granted why
security-audit contents: read, pull-requests: write The 'Comment audit result on PR' step runs gh pr comment, which needs pull-requests: write (this also covers gh pr diff); actions/checkout needs contents: read. The existing issues: write grant was dropped because no step touches issues, but if gh pr comment fails without it, re-add it.

Anything not listed above keeps the permissions it had. To measure a job this could not read, add GitHubSecurityLab/actions-permissions/monitor to it and run the workflow — it reports the minimum the run actually used.

Claude decided the scopes each job needs; the YAML was edited by code. Read the table below before merging.

dependabot Bot and others added 2 commits October 14, 2026 18:27
Bumps the actions group with 7 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [actions/checkout](https://github.com/actions/checkout) | `7.0.0` | `7.0.1` |
| [DeterminateSystems/nix-installer-action](https://github.com/determinatesystems/nix-installer-action) | `22` | `23` |
| [cachix/cachix-action](https://github.com/cachix/cachix-action) | `5f2d7c5294214f71b873db4b969586b980625e71` | `38b082610b782e7e93e209c35fd730d399dee866` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `7.0.1` | `7.0.2` |
| [actions/download-artifact](https://github.com/actions/download-artifact) | `8.0.1` | `8.0.2` |
| [actions/setup-python](https://github.com/actions/setup-python) | `6.3.0` | `7.0.0` |
| [actions/setup-node](https://github.com/actions/setup-node) | `6.4.0` | `7.1.0` |



Updates `actions/checkout` from 7.0.0 to 7.0.1
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@9c091bb...3d3c42e)

Updates `DeterminateSystems/nix-installer-action` from 22 to 23
- [Release notes](https://github.com/determinatesystems/nix-installer-action/releases)
- [Commits](DeterminateSystems/nix-installer-action@ef8a148...3138316)

Updates `cachix/cachix-action` from 5f2d7c5294214f71b873db4b969586b980625e71 to 38b082610b782e7e93e209c35fd730d399dee866
- [Release notes](https://github.com/cachix/cachix-action/releases)
- [Changelog](https://github.com/cachix/cachix-action/blob/master/RELEASE.md)
- [Commits](cachix/cachix-action@5f2d7c5...38b0826)

Updates `actions/upload-artifact` from 7.0.1 to 7.0.2
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@043fb46...cf430e0)

Updates `actions/download-artifact` from 8.0.1 to 8.0.2
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@3e5f45b...9000827)

Updates `actions/setup-python` from 6.3.0 to 7.0.0
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@ece7cb0...5fda3b9)

Updates `actions/setup-node` from 6.4.0 to 7.1.0
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](actions/setup-node@48b55a0...949feb2)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: DeterminateSystems/nix-installer-action
  dependency-version: '23'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: cachix/cachix-action
  dependency-version: 38b082610b782e7e93e209c35fd730d399dee866
  dependency-type: direct:production
  dependency-group: actions
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/download-artifact
  dependency-version: 8.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: actions/setup-python
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: actions/setup-node
  dependency-version: 7.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot
dependabot Bot force-pushed the dependabot/github_actions/actions-c20c00cd42 branch from bd4abcd to 3d3196e Compare October 27, 2026 19:35
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.

0 participants