Skip to content

fix(ci): harden GitHub Actions workflows (#249) - #250

Merged
paulinebm merged 1 commit into
dependabot/github_actions/actions-3a38c001b3from
security/workflow-hardening/pr-249
Sep 17, 2026
Merged

paulinebm merged 1 commit into
dependabot/github_actions/actions-3a38c001b3from
security/workflow-hardening/pr-249

Conversation

@hf-security-analysis

@hf-security-analysis hf-security-analysis Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Automated hardening of the workflow files flagged on #249.

Warning

This narrows what the workflow can reach. Job permissions were declared in .github/workflows/build_documentation.yml, .github/workflows/build_pr_documentation.yml, .github/workflows/quality.yml, .github/workflows/test_models.yml, .github/workflows/test_models_nightly.yml. Each job now gets only the scopes its steps were read to need — if one of them does something this could not see, it will fail on the next run. The table below says which step drove each scope.

Targets dependabot/github_actions/actions-3a38c001b3. Files changed:

  • .github/workflows/build_documentation.yml
  • .github/workflows/build_pr_documentation.yml
  • .github/workflows/quality.yml
  • .github/workflows/test_models.yml
  • .github/workflows/test_models_nightly.yml

Fixed by this PR:

  • HIGH unpinned-action (pinact) — .github/workflows/build_documentation.yml:20
  • HIGH unpinned-action (pinact) — .github/workflows/build_documentation.yml:21
  • HIGH unpinned-action (pinact) — .github/workflows/build_documentation.yml:27
  • HIGH unpinned-action (pinact) — .github/workflows/build_pr_documentation.yml:22
  • HIGH unpinned-action (pinact) — .github/workflows/build_pr_documentation.yml:23
  • HIGH unpinned-action (pinact) — .github/workflows/build_pr_documentation.yml:29
  • HIGH unpinned-action (pinact) — .github/workflows/build_pr_documentation.yml:60
  • HIGH unpinned-action (pinact) — .github/workflows/test_models.yml:19
  • HIGH unpinned-action (pinact) — .github/workflows/test_models.yml:51
  • HIGH unpinned-action (pinact) — .github/workflows/test_models.yml:53
  • HIGH unpinned-action (pinact) — .github/workflows/test_models_nightly.yml:20
  • HIGH unpinned-action (pinact) — .github/workflows/test_models_nightly.yml:47
  • HIGH unpinned-action (pinact) — .github/workflows/test_models_nightly.yml:49
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/build_documentation.yml:1
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/build_documentation.yml:12
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/build_pr_documentation.yml:1
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/build_pr_documentation.yml:13
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/quality.yml:1
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/quality.yml:16
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/test_models.yml:1
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/test_models.yml:14
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/test_models.yml:31
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/test_models_nightly.yml:1
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/test_models_nightly.yml:15
  • MEDIUM excessive-permissions (zizmor) — .github/workflows/test_models_nightly.yml:30

This does not fix everything. 3 further finding(s) (1 high, 2 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_documentation.yml

job granted why
build_documentation contents: read actions/checkout needs contents: read; the only publishing step (doc-builder push) targets the Hugging Face hub repo using the separate HF_TOKEN secret, so no GITHUB_TOKEN write scopes are required.

.github/workflows/build_pr_documentation.yml

job granted why
build_documentation contents: read Only actions/checkout needs the token (contents: read); the doc-builder build steps and actions/upload-artifact (same-run artifact) require no additional scopes.

.github/workflows/quality.yml

job granted why
quality contents: read Only actions/checkout needs the token (contents: read); the remaining steps just install pip packages and run black/ruff locally, which use no API access.

.github/workflows/test_models.yml

job granted why
discover-tests contents: read Only actions/checkout plus a local find/sed shell step that writes a matrix to $GITHUB_OUTPUT, so checkout's contents: read is the widest need.
run-tests contents: read Checkout, setup-python, disk/swap shell tweaks and pytest only consume already-checked-out code; the python install_dev.py step is a repo script not visible here, but it installs dependencies and shows no API/token use, so contents: read suffices — reviewer may want to confirm that script.

.github/workflows/test_models_nightly.yml

job granted why
discover-tests contents: read Only actions/checkout plus a local find/sed shell step that writes to GITHUB_OUTPUT, so read access to the repository contents is all that is required.
run-tests contents: read Checkout drives the only token use; the remaining steps set up Python, resize swap, run python install_dev.py (a repo script not shown here, but it only installs pip dependencies) and execute pytest locally, with no API or artifact publishing calls.

.github/workflows/upload_pr_documentation.yml

build was left as it is — This job only declares uses: to call the external reusable workflow huggingface/doc-builder@17ccdf17, whose steps are not visible in this file; it likely needs actions: read to fetch the build artifact from the triggering workflow run and pull-requests: write for the comment bot, but the called workflow should be inspected to confirm.

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.

Pinning changes come from pinact and are mechanical. Any other change was generated by Claude — read it before merging.

@paulinebm
paulinebm merged commit 3b2523d into dependabot/github_actions/actions-3a38c001b3 Sep 17, 2026
@paulinebm
paulinebm deleted the security/workflow-hardening/pr-249 branch September 17, 2026 13:47
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